[vox-tech] Bash scripting newbie - need syntax help

Ken Bloom vox-tech@lists.lugod.org
Thu, 29 Apr 2004 10:00:30 -0700


--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Apr 28, 2004 at 11:57:13PM -0700, Larry Ozeran wrote:
> Thanks Ken.
>=20
> I had not seen quotes working from the first find suggestion:
> Consider another direction:
> $ find /var/log -iname \*.[0-9].[0-9] -print0 | xargs -r0 rm -f

And you attempted:
find -iname \erro*.[1-4].[1-4] -print0 | xargs -r0 rm -f

The point of the backslash in these two examples was to supress the
expansion of the * character by using \* to make the shell pass the *
on literally.

The command:
find -iname \erro*.[1-4].[1-4] -print0 | xargs -r0 rm -f
would need to be rewritten as:
find -iname erro\*.[1-4].[1-4] -print0 | xargs -r0 rm -f

Replacing a character "c" with "\c" is a common way that computer
languages change the meaning of a character to/from something special.
This convention was adopted from C where \n means a newline, \t means
a tab, and \\ means a literal backslash. Thus, in order for the
backslash to have the desired effect, it needs to go immediately
before the *.

>=20
> The quotes are indeed necessary. It worked!
>=20
> Thanks again to everyone who contributed.
>=20
> - Larry
>=20
> *********** REPLY SEPARATOR  ***********
>=20
> On 4/28/04 at 10:39 PM Ken Bloom wrote:
>=20
> >You *need* to put the pattern in quotes, because otherwise the shell
> >will perform wildcard expansion just the same way it was doing for the
> >rm command. Try=20
> >find -iname 'erro*.[1-4].[1-4]' -print0 | xargs -r0 rm -f
> >This should stop the nasty expansion.
> >
> >This was demonstrated implicitly before, as Foo Lim said:
> >> >
> >> >Try using xargs like this:
> >> >
> >> >find . -name "error*" | xargs rm
> >> >
> >> >You can also try doing it through the find command like this:
> >> >
> >> >find . -name "error*" -exec rm \{} \;
> >
> >--=20
> >I usually have a GPG digital signature included as an attachment.
> >See http://www.gnupg.org/ for info about these digital signatures.
> >My key was last signed 10/14/2003. If you use GPG *please* see me about=
=20
> >signing the key. ***** My computer can't give you viruses by email. ***
> >
> >-----BEGIN PGP SIGNATURE-----
> >Version: GnuPG v1.2.4 (GNU/Linux)
> >
> >iD8DBQFAkJUOlHapveKyytERAlp9AKCjezddTAWH0y9Ips0EGSo597t2twCaApFS
> >u2frUtwdexqyfvAdzYYQgho=3D
> >=3Dct7r
> >-----END PGP SIGNATURE-----
> >
> >_______________________________________________
> >vox-tech mailing list
> >vox-tech@lists.lugod.org
> >http://lists.lugod.org/mailman/listinfo/vox-tech
>=20
>=20
> - Larry
>=20
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org

--=20
I usually have a GPG digital signature included as an attachment.
See http://www.gnupg.org/ for info about these digital signatures.
My key was last signed 10/14/2003. If you use GPG *please* see me about=20
signing the key. ***** My computer can't give you viruses by email. ***

--xHFwDpU9dbj6ez1V
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAkTStlHapveKyytERAuhdAJwKzS1wO/vJOUq3fnTSzJlqp4lzuACggW+S
jPt5TrfsPZ68S/mvRgf3sqM=
=QMaM
-----END PGP SIGNATURE-----

--xHFwDpU9dbj6ez1V--