LinuxQuestions.org
Review your favorite Linux distribution.
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 07-30-2012, 09:08 PM   #1
Leath
LQ Newbie
 
Registered: May 2012
Posts: 11

Rep: Reputation: Disabled
find and rename command


Hi gurus,

I have this nifty command which finds and renames files wthat have a colon : in them. It works well on my ubuntu box at home, but I can't seem to get it to run properly at work. Any one have any idea why that would be and how I can get around it?

The find command on it's own returns the correct results.

Quote:
find Directory_to_search/ -name "*:*" -exec rename -v 's/:/#/' {} +
Home - ubuntu build from a couple months ago.
work - CentOS 2.16.0 (old one from 2007)

On a side note - can anyone think of a reason I shouldn't replace the : with a #? I was going to use # so it was easy to revert it back later.

Thanks in advance.

Last edited by Leath; 07-30-2012 at 09:34 PM.
 
Old 07-30-2012, 10:50 PM   #2
Leath
LQ Newbie
 
Registered: May 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
FYI - I managed to get this working with the help of a knowledgable colleague. For this version of rename the correct method was to use single quotes as below:

Quote:
find Directory_to_search/ -name "*:*" -exec rename ':' '#' {} +
 
Old 07-30-2012, 11:13 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,329

Rep: Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745
I'd be a bit careful of using '#', as that is the 'comment starts here' Special Char in bash (all shells actually)
 
Old 07-30-2012, 11:36 PM   #4
Leath
LQ Newbie
 
Registered: May 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
thanks chrism01,

For the real case I replaced the colon with a distinct word which wasn't used anywhere in the files - made it easy to change and then revert the changes back.
 
  


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
Find and Rename files made by Windoze users wademac Linux - Newbie 5 09-22-2009 10:18 AM
Got me going crazy? unable to rename using mv command!!! close2me Linux - General 4 05-09-2007 02:42 AM
rename command does not work! wtn2die Linux - General 6 12-27-2006 12:00 PM
rename reboot command coco03 Linux - General 6 04-19-2005 03:11 AM
rename with command line shanenin Linux - Software 1 09-25-2003 08:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:06 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
Open Source Consulting | Domain Registration