LinuxQuestions.org
Help answer threads with 0 replies.
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 11-08-2007, 04:37 PM   #1
Yig
Member
 
Registered: Aug 2005
Location: Montreal, Qc
Distribution: CentOs 4.5/5.0
Posts: 113

Rep: Reputation: 15
Searching for files with special characters


Hi,

I'm trying to do a search for files whose name start with #.

All the files look like this:

#cvs.rfl.castor-srvr4.benchmarkcanada.com.19844

Only thing that change is the number at the end.

Problem is, if I go in a directory where I know one of those file is, if I do a find -name #cvs it does not work. I tried to put it between "" but that didn't work either.

Those files are CVS lock files.

So, what is the command I need to execute to find them?

Thanks!
 
Old 11-08-2007, 04:59 PM   #2
griffey
Member
 
Registered: Jan 2004
Location: East Central Illinois
Distribution: RHEL 4/5/6 and Fedora
Posts: 81

Rep: Reputation: 15
You might try "locate."

Depending on whether or not the mlocate database has been created/updated, you might have to run "updatedb" as root first.

I created a file "#myfile" and updated the database, and typed

locate "#"

(I had to use the quotes) and it admittedly found all files with # anywhere in them (so you may get more back than you bargained for).

If you're better with regular expressions than I am you might have better luck. (Something like \#[A-Za-z0-9]+ ??)

Good luck.

G.--
 
Old 11-08-2007, 05:06 PM   #3
Yig
Member
 
Registered: Aug 2005
Location: Montreal, Qc
Distribution: CentOs 4.5/5.0
Posts: 113

Original Poster
Rep: Reputation: 15
Great! That worked!

Thanks a lot!

Is there a way to search and delete those files in one step?

Something like

rm 'locate "#cvs.rfl"'

Would that work?
 
Old 11-08-2007, 05:13 PM   #4
griffey
Member
 
Registered: Jan 2004
Location: East Central Illinois
Distribution: RHEL 4/5/6 and Fedora
Posts: 81

Rep: Reputation: 15
Heh. I don't think so.

I'm sure there are WAY more clever ways of doing this, but what I would do in this situation is output that list of files to a text file first.

locate "#" >> cat mylist.txt

Then I would cheat and copy that file to my Mac and search-and-replace all instances of a carriage return and change each carriage return to carriage return + "rm ". You'd have to manually add the "rm " at the first line.

Then you should have a text file with all of the files listed, with "rm " in front of them.

Copy that back to the linux box, make the file executable (chmod +x mylist.txt), and then execute it (./mylist.txt).

Or something like that.

Someone else might (hopefully) have a more clever way of doing it, but that's probably what I would try.

Good luck!

G.--
 
Old 11-08-2007, 06:53 PM   #5
peart
Member
 
Registered: Nov 2003
Distribution: Arch
Posts: 31

Rep: Reputation: 16
find . -name "#cvs*" -exec rm {} \;
 
  


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
Special Characters SimeonV SUSE / openSUSE 14 07-07-2006 02:29 PM
ignoring special characters fredyk_ Linux - General 3 06-19-2006 10:50 AM
special characters greenbox Linux - Software 9 12-23-2005 08:33 PM
Special characters consty Programming 3 08-07-2005 06:53 AM
using special characters one_ro Mandriva 5 11-04-2004 09:52 AM


All times are GMT -5. The time now is 11:04 PM.

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