l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2004 Apr 30 01:25

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Bash scripting newbie - need syntax help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



Thanks again Ken. That's the problem with the ignorant, we just don't know the importance of each symbol / character in the answer. I didn't want to use the recommendation as it was because I only wanted to remove the error* files. I (incorrectly) assumed the slash was marking parameters rather than ensuring the * was passed as an uninterpreted character. Now I see why either erro\* or "erro*" would work.

I guess it's time to get educated. Definitely not enough info in the bash man page for me to become effective with it. Does anyone want to suggest a bash tutorial?

- Larry

*********** REPLY SEPARATOR  ***********

On 4/29/04 at 10:00 AM Ken Bloom wrote:

>On Wed, Apr 28, 2004 at 11:57:13PM -0700, Larry Ozeran wrote:
>> Thanks Ken.
>>
>> 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 *.
>
>>
>> The quotes are indeed necessary. It worked!
>>
>> Thanks again to everyone who contributed.
>>
>> - Larry
>>
>> *********** REPLY SEPARATOR  ***********
>>
>> On 4/28/04 at 10:39 PM Ken Bloom wrote:
>>
>> >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
>> >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 \{} \;
>> >
>> >--
>> >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
>> >signing the key. ***** My computer can't give you viruses by email. ***
>> >
>> >-----BEGIN PGP SIGNATURE-----
>> >Version: GnuPG v1.2.4 (GNU/Linux)
>> >
>> >iD8DBQFAkJUOlHapveKyytERAlp9AKCjezddTAWH0y9Ips0EGSo597t2twCaApFS
>> >u2frUtwdexqyfvAdzYYQgho=
>> >=ct7r
>> >-----END PGP SIGNATURE-----
>> >
>> >_______________________________________________
>> >vox-tech mailing list
>> >vox-tech@lists.lugod.org
>> >http://lists.lugod.org/mailman/listinfo/vox-tech
>>
>>
>> - Larry
>>
>> _______________________________________________
>> vox-tech mailing list
>> vox-tech@lists.lugod.org
>
>--
>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
>signing the key. ***** My computer can't give you viruses by email. ***
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.2.4 (GNU/Linux)
>
>iD8DBQFAkTStlHapveKyytERAuhdAJwKzS1wO/vJOUq3fnTSzJlqp4lzuACggW+S
>jPt5TrfsPZ68S/mvRgf3sqM=
>=QMaM
>-----END PGP SIGNATURE-----
>
>_______________________________________________
>vox-tech mailing list
>vox-tech@lists.lugod.org
>http://lists.lugod.org/mailman/listinfo/vox-tech


- Larry

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.