[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need help making shell script use two CPUs/cores



In <[🔎] 20110110000500.46F09BFCA@kev.msw.wpafb.af.mil>, Karl Vogel wrote:
>>> On Sun, 09 Jan 2011 10:05:43 -0600,
>>> Stan Hoeppner <stan@hardwarefreak.com> said:
>S> #! /bin/sh
>S> for k in $(ls *.JPG); do convert $k -resize 1024 $k; done
>
>   Someone was ragging on you to let the shell do the file expansion.  I
>   like your way better because most scripting shells aren't smart enough
>   to realize that when there aren't any .JPG files, I don't want the
>   script to echo '*.JPG' as if that's actually useful.

$(ls *.ext) splits into arguments at each run of shell-whitespace in the ls 
output.
*.ext splits into arguments at the end of each filename.
If you want to do the right thing, independent of the characters in the 
filenames and the value of the IFS environment variable, use the later.

TL;DR: *.ext work when filenames contain spaces; $(ls *.ext) doesn't.
-- 
Boyd Stephen Smith Jr.                   ,= ,-_-. =.
bss@iguanasuicide.net                   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy         `-'(. .)`-'
http://iguanasuicide.net/                    \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: