Re: Change filenames recursively

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 31, 2007 at 03:57:30PM -0500, Matthew Anderson wrote:
> I have hundreds of files that start with a * (asterisk) for the
> filename.  I am needing to change the asterisk in every file to a _
> (underscore).  Does
> 
> Anyone know what command I can use to recursively do that?  I appreciate
> any help anyone can provide me.

The following should work:

  for i in `find . -type f -name '\**'`; do mv $i `echo $i | sed -e 's/\*/_/g'`; done 

This will only work if there is one '*' in the filename as the sed command
replaces all asterisks with underscores.  You can adjust if your needs differ.

Ray

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux