[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] quick bash script question
- Subject: [ale] quick bash script question
- From: hne at hopnet.net (Keith Hopkins)
- Date: Tue, 13 May 2003 08:09:36 +0900
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