Help - Search - Members - Calendar
Full Version: BASH to strip underscores?
Linuxhelp > Support > Programming in Linux
I have several pictures in a directory. They all look like: first_last.jpeg

I'd like a simple bash script to rename any that have an unscore, so they all look like: firstlast.jpeg

do something like this:
$ ls|sed -e 's/_//g'
Hemant need script to rename files...sorry abt that:
for x in `ls`; do y=`echo $x|sed 's/\_//'`; mv $x $y; done

But this script will only remove only one underscore from filenames so beware!!

PS: or run it twice to remove more than one underscores!! In each will remove one underscore..
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.