Replace spaces in filename

for i in *\ *; do if [ -f "$i" ]; then mv "$i" ${i// /_}; fi; done
This command will replace spaces in filename with underscore, for all file in directory that contain spaces.

1
By: auriza
2010-01-02 16:30:45
mv

2 Alternatives + Submit Alt

What Others Think

This works in absence of the "rename" Perl script. But doesn't rename come with Perl5?
kaedenn · 683 weeks ago
At least on debian/ubuntu systems I use, after you install the 'perl' package, /usr/bin/rename (a symlink) points to the perl script /usr/bin/prename. The util-linux rename command which was available before, is still there and named /usr/bin/rename.ul, and you can still get to its manpage via 'man rename.ul' .
bwoodacre · 682 weeks and 6 days ago
Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale pug puppies indiana Amazing! This blog looks just like my old one! It's on a completely different subject but it has pretty much the same layout and design. Wonderful choice of colors!
rahimhh21 · 22 weeks and 1 day ago
This website and I conceive this internet site is really informative ! Keep on putting up! Warmtepompen
seomind · 15 weeks ago
Amazing knowledge and I like to share this kind of information with my friends and hope they like it they why I do Zwembad bouwen
seomind · 15 weeks ago
I would also motivate just about every person to save this web page for any favorite assistance to assist posted the appearance. Thuisbatterij
seomind · 15 weeks ago
I really enjoy reading and also appreciate your work. Laser ontharen
seomind · 15 weeks ago
Very nice blog and articles. I am realy very happy to visit your blog. Now I am found which I actually want. I check your blog everyday and try to learn something from your blog. Thank you and waiting for your new post. Pergola's
seomind · 15 weeks ago
I found Hubwit as a transparent s ite, a social hub which is a conglomerate of Buyers and Sellers who are ready to offer online digital consultancy at decent cost. Warmtepomp installatie
seomind · 15 weeks ago
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. Geothermische warmtepomp
seomind · 14 weeks and 6 days ago
It has fully emerged to crown Singapore's southern shores and undoubtedly placed her on the global map of residential landmarks. I still scored the more points than I ever have in a season for GS. I think you would be hard pressed to find somebody with the same consistency I have had over the years so I am happy with that. Terrasoverkappingen
seomind · 14 weeks and 6 days ago
Hey, great blog, but I don’t understand how to add your site in my rss reader. Can you Help me please? Airco
seomind · 14 weeks and 6 days ago
very interesting post.this is my first time visit here.i found so many interesting stuff in your blog especially its discussion..thanks for the post! Lucht/water warmtepomp
seomind · 14 weeks and 6 days ago
Hi buddies, it is great written piece entirely defined, continue the good work constantly. Airco
seomind · 14 weeks and 6 days ago
There is definately a great deal to know about this subject. I like all of the points you've made. Vloerisolatie
seomind · 14 weeks and 6 days ago
I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. Airco installatie
seomind · 14 weeks and 6 days ago
There is definately a great deal to know about this subject. I like all of the points you've made. Zwembad tuin
seomind · 14 weeks and 6 days ago
Your work is very good and I appreciate you and hopping for some more informative posts Lucht/water warmtepompen
seomind · 14 weeks and 6 days ago
very interesting post.this is my first time visit here.i found so many interesting stuff in your blog especially its discussion..thanks for the post! Zwembad aanleggen tuin
seomind · 14 weeks and 6 days ago
My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more! Airconditioning
seomind · 14 weeks and 6 days ago
It has fully emerged to crown Singapore's southern shores and undoubtedly placed her on the global map of residential landmarks. I still scored the more points than I ever have in a season for GS. I think you would be hard pressed to find somebody with the same consistency I have had over the years so I am happy with that. Chape
seomind · 14 weeks and 6 days ago
Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies baby pug puppies for sale pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale
Perfecthomepugs · 13 weeks and 5 days ago
I have to search sites with relevant information on given topic and provide them to teacher our opinion and the article. Viagra
seomind · 12 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: