Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> BASH to strip underscores?
Termina
post Feb 2 2006, 09:41 AM
Post #1


RMS is my Hero
******

Group: Support Specialist
Posts: 862
Joined: 18-February 04
From: Wisconsin
Member No.: 2,404



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

Thanks


--------------------
*Points finger at the author above him* They're a witch! Burn them!
---
Vist my website!
Join me in IRC! Server: st0rage.org Channel: #UnhandledExceptions
Go to the top of the page
 
+Quote Post
Hemant
post Feb 6 2006, 08:59 AM
Post #2


RMS is my Hero
******

Group: Support Specialist
Posts: 782
Joined: 6-October 02
From: Trichy,INDIA
Member No.: 29



do something like this:
CODE
$ ls|sed -e 's/_//g'


--------------------
Hemant Kumar
user posted image
hemant@linuxhelp.net
Go to the top of the page
 
+Quote Post
Hemant
post Feb 6 2006, 09:31 AM
Post #3


RMS is my Hero
******

Group: Support Specialist
Posts: 782
Joined: 6-October 02
From: Trichy,INDIA
Member No.: 29



Ohh...you need script to rename files...sorry abt that:
CODE
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 run..it will remove one underscore..


--------------------
Hemant Kumar
user posted image
hemant@linuxhelp.net
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 17th October 2017 - 02:53 AM