Prev: Question regarding libgtk2.0-dev on Linux
Next: controlling fanspeed - gnome lenny - acer laptop
From: Boyd Stephen Smith Jr. on 29 Jul 2010 12:20 On Thursday 29 July 2010 05:27:35 Mart Frauenlob wrote: > On 29.07.2010 07:17, Boyd Stephen Smith Jr. wrote: > > On Wednesday 28 July 2010 21:37:44 Karl Vogel wrote: > >> I need to think before posting. I didn't mention that I have > >> FreeBSD, Linux, and Solaris boxes, and unfortunately I can't > >> guarantee the same access to GNU find. I can install xargs if the > >> system version doesn't recognize the "-0" option, so I usually end > >> up scripting for the lowest common denominator. > > > > In that case, you'll have to be very careful in order to handled file > > names that contain IFS characters or newlines: > > > > find "$MAGDIR" -name "*.[zZ][iI][pP]" -exec \ > > > > sh -c 'handle_single_file "$1"' ignored {} \; > > > > That will work on any POSIX system, or most systems with POSIX-conforming > > find and sh. You *may* have to specify full paths to the > > POSIX-conforming find and sh commands. > > yes, '-exec command {} +' is also POSIX, but newer (collects argument > list similar to xargs). In that case, you may be able to avoid spawning quite as many processes by doing something like: find "$MAGDIR" -name "*.[zZ][iI][pP]" -exec \ sh -c 'handle_many_files "$@"' ignored {} + Note that I used the "-exec cmd \;" form explicitly because the "-exec cmd +" form is newer. > I think using '-type f' would not be wrong either, as otherwise we would > match directories also. Probably not a bad idea. -- Boyd Stephen Smith Jr. ,= ,-_-. =. bss(a)iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/
From: Chris Davies on 30 Jul 2010 07:30 Karl Vogel <vogelke+debian(a)pobox.com> wrote: > for file in $(ls $MAGDIR/*.[Zz][Ii][Pp] 2> /dev/null); do ... mkdir $MAGDIR/silly.zip touch $MAGDIR/silly.zip/not-a-zip-file If you're going to insist on using "ls" you should consider "ls -d". Personally, I'd still go for this construct: for FILE in "$MAGDIR"/*.[Zz][Ii][Pp] do test -f "$FILE" || continue ... But each to our own. Chris -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org Archive: http://lists.debian.org/tlnai7x1ch.ln2(a)news.roaima.co.uk
First
|
Prev
|
Pages: 1 2 3 4 Prev: Question regarding libgtk2.0-dev on Linux Next: controlling fanspeed - gnome lenny - acer laptop |