LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-24-2011, 06:54 PM   #1
Allis
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Rep: Reputation: Disabled
Removing # from file names


So I would like to remove the '#' symbol from all my file names. I tried the following but that didn't work. I think I might be using the wrong escape character.
 
Old 12-24-2011, 07:14 PM   #2
Allis
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Figured it out. Thank you.

rename 's/\#//' *
 
Old 12-25-2011, 06:59 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Glad you worked it out. Please mark the thread as solved.

But for a bit of clarification, the command you used is actually the perl-based prename script, which is linked to rename in many debian-based distributions through /etc/alternatives. It's very handy, but not every system has it installed.

Since the perl syntax uses regular expressions, targeting individual characters is probably better done using character classes:
Code:
rename 's/[#]//g' *
Adding "g" (for "global") at the end tells it to replace all instances of that character (or characters; class brackets can hold lists or ranges) in the line, otherwise it only replaces the first one found.


And two more polite suggestions:

The topic of renaming files comes up regularly. Please try to do a few searches of the archives and/or web before posting common questions like this.

Finally, please use [code][/code] tags around your code and data, to preserve formatting and to improve readability.

Last edited by David the H.; 12-25-2011 at 07:02 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash: bash file names are different than openbox trash file names whatthefunk Programming 4 02-15-2011 02:52 AM
[SOLVED] How to changing same file names by their directory names? bayaraa_u Linux - General 3 04-09-2010 09:26 AM
/bin/tar: Removing leading `/' from member names guarriman Linux - General 16 02-09-2010 09:19 PM
/bin/tar: Removing leading `/' from member names IFeelYourPain Linux - General 11 12-01-2007 03:32 PM
RHEL3 - removing disks shifts LVM dev names downward? QuantSuff Linux - Server 2 06-04-2007 12:58 PM


All times are GMT -5. The time now is 02:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration