[ale] quick bash script question

Keith Hopkins hne at hopnet.net
Mon May 12 19:09:36 EDT 2003


Hi CB,

Christopher Bergeron wrote:
> Hi guys - Ok, so I wrote a little script to replace my "locate" command:
> 
> #!/bin/bash
> for i in `/usr/bin/locate.orig $1`; do
> ~  ls -l -h --color "$i";
> done
> 
[snip]
> 
> Is there a way to fix this, or can anyone explain why it's doing this?

   It does this because the bash parser considers non-quoted white space (space, tabs, etc) as a field seperator, and "for" reads fields.

   Try this instead....

#!/bin/bash
/usr/bin/locate.orig $1 | while read i ; do
           ls -l -h --color "$i";
done

   This works because "read" reads whole lines, not fields.

-- 
Lost in Tokyo,
   Keith


_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list