[ale] scripting (looping through filenames containing spaces)
Cleveland Flowe
flowe at switchco.com
Tue Jul 4 01:40:51 EDT 2000
Ben Phillips wrote:
>
> SHORT STORY:
>
> Fix the script below so it outputs the following:
>
> a b c
> 1 2 3
>
> It's important that the backquotes (or some other command-substition) be
> there. The idea is to get 'for' to recognize tokens that have whitespace
> characters in their names.
>
> ------------------------------------------
> #! /bin/bash
> #
> # Loop through output that contains spaces
> #
>
> for i in `echo \"a b c\"; echo \"1 2 3\"`;
> do echo $i
> done
> ------------------------------------------
Here's something that does what you want...
#!/bin/bash
find $1 -type d | while read dir; do
lcdir="`echo $dir | tr '[A-Z]' '[a-z]'`"
if test "$lcdir" != "$dir"; then
mv -i "$dir" "$lcdir"
fi
done
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list