[prog] Bash script blues

Kathryn Hogg kjh at flyballdogs.com
Fri Aug 26 00:20:27 EST 2005


Wolfgang Petzold said:
>
> $ ls -1 $HOUSE | grep .torrent | while read filename ; do \
> 	mv "$filename" `echo "$filename" | sed -e 's/ /_/g;'` \
> done

You probably should protect the 2nd file name in case it has characters
that the shell might interpret like parens, semicolons, etc:

for file in *.torrent
do
   mv "$file" "$(echo $file | tr '[:blank"] _)"
done

-- 
Kathryn
http://womensfooty.com



More information about the Programming mailing list