[lug] bash scripting question

Stephen Queen svqueen at gmail.com
Fri Nov 18 09:57:57 MST 2005


On 11/18/05, Hugh Brown <hugh at math.byu.edu> wrote:
> I've had this problem a few times and haven't found a quick way to get
> around it.  I often do per file operations at the bash prompt with
> something like this:
>
> for i in `ls`; do
> command $i| othercommand
> done
>
> The problem is that if the files have spaces in them, then things break.
>
> Is there some bash'ism that would allow me to get this to work.
>
>
>
> Hugh
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
>

How about

oldifs=$IFS; IFS="" ; for i in `ls WinXP` ; do command "$i" |
othercommand ; done ; export IFS=$oldifs

Stephen



More information about the LUG mailing list