[wplug] Slightly off topic...shell script

Michael E Uhl meu102 at comcast.net
Sat Feb 12 16:50:25 EST 2005


Instead of: 

for i in *.txt; do mv "$i" `echo $i | tr '---' '-'`;

try:

for i in *.txt; do mv "$i" `echo $i | tr -s '-'`;

The "-s" option (short for --squeeze-repeats) of "tr" eliminates
duplicate characters.

-michael

On Fri, 2005-02-11 at 17:11, Dileep Vangasseri wrote:
> Hello,
> 
> I have a set of files having names which has
> characters --- in between (like foo---test--to.txt). I
> want to replace '---' with a '-' (single dash). Can
> anyone suggest a script which would make my life
> simple?
> 
> I tried:
> 
> for i in *.txt; do mv "$i" `echo $i | tr '---' '-'`;
> done
> 
> But it is not taking the --- as one character. Can
> anyone suggest a way out?
> 
> Regards,
> 
> Dileep
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
-- 
Michael Edward Uhl
-------------------------------------------
GPG (www.gnupg.org) Public Key
http://home.comcast.net/~meu102/pub_key.asc
Finger Print:
FBBD 1F4D 5A70 AF45 29DB  5942 ED92 9DAF F01C 4472



More information about the wplug mailing list