Got it with echo, so mv is next. TYVM!!

I use this substitution form in Vim all the time, just never occurred to 
me to use it in the commandline like that.

for i in "*\&amp*"; do echo "${i/\&/and/}"; done

Curiously, there's a forgiving anomaly. The 1st time I left off the last 
trailing slash and it worked.

Thanks again, chutsu!


chutsu wrote:
> Well I think the follow code will help you
>
> for i in *;do mv "$i" "${i/\&amp/} done;
>
> -So basically the for loop runs through every file in that particular
> directory.
> -Uses the "mv" command to rename files, the second statement is just
> search and replace
> -The "/\&amp/" means I want to search the term "&amp" and replace it
> with "something".
> -NOTE: the "\" infront of the "&", because you need to escape special
> symbols such as "%" "-" etc ...
> -After the second "/" in the search and replace term you can put
> whatever you want...
>  eg.) if I wanted to replace "&amp" with "HELLO" the move command will
> be:
>
> mv "$i" "${i/\&amp/HELLO}"
>
> Hope this helps :)
> Chris
>
> On Dec 21, 5:15 pm, tuxsun1 <[email protected]> wrote:
>   
>> I have always used Bash variable substitution chars (#, ##, %, %%) to
>> rename files when replacing the beginning or end of a filename.
>>
>> Now I have a need to replace the middle portion of filenames from their
>> html code, '&amp;', to 'and'.
>>
>> e.g. list of filenames
>>
>> Payables &amp; Receivables
>> Sales &amp; Marketing
>> Shipping &amp; Receiving
>>
>> Normally, I would use something like, for i in '*&amp*'; do mv "$i"
>> (this is where I'm stumped); done
>>
>> TIA!
>>     
>
>   

-- 
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit our group at 
http://groups.google.com/group/linuxusersgroup

Reply via email to