LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-14-2004, 02:05 PM   #1
naps
Member
 
Registered: Aug 2003
Distribution: 10.3
Posts: 39

Rep: Reputation: 15
Question Command line tools to Find files with specific text


What is the best tool to find all files with a string such as "PS1=" ?
I solved this one by letting the Find Files icon in KDE sort through the whole hard drive.
If I knew the likely candidates I could use cat | grep "PS1=" or maybe awk (just discovered this today). In DOS I would use For...in...do...find... but that does rely on knowing the likely candidates (usually by the three letter extensions).
Any suggestions?
Naps
 
Old 11-14-2004, 02:38 PM   #2
mithrascruor
LQ Newbie
 
Registered: Oct 2004
Distribution: Debian
Posts: 18

Rep: Reputation: 0
What's wrong with just using grep?

something like:
Code:
grep -r -I -D skip "PS1=" /
-r : recursive
-I : ignore binary files
-D skip : skip device drivers

--
Kyle
 
Old 11-14-2004, 02:59 PM   #3
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: LFS-Version SVN-20091202, Arch 2009.08
Posts: 1,488

Rep: Reputation: 67
Yea or so you can remeber that make a bash script so that it will run with them commands and you got your own home made search engine
 
Old 11-14-2004, 04:56 PM   #4
naps
Member
 
Registered: Aug 2003
Distribution: 10.3
Posts: 39

Original Poster
Rep: Reputation: 15
Thanks for the speedy replies, Mithrascruor and Exvor. More success using the / instead of the * I had used before. I don't know what's wrong but it goes through the windows directories twice, then after a couple of grep /proc entries, which return Invalid Argument, it stops. (I copied the windows partitions over to this box for the data, though I don't run it on this box). I don't know if this is peculiar to my distro Suse 9.1; I tried it on my laptop, which has a Debian based distro (Libranet 2.8.1) which would not run with the -D switch. It did find my .bashrc file in my home directory (I think SuSE makes it more difficult by using etc/profile referring to /etc/profile.local or some complex set-up) but then it stops after two "no such file or directory" entries in a /~/.kde directory.
Perhaps it is running out of memory (500Mb on the desktop and 384 on the laptop)? I would have thought it would crash more readily with a GUI, but maybe SuSE has built in a work-around for this?
Naps
 
Old 11-14-2004, 06:19 PM   #5
Adrohak
Member
 
Registered: Jun 2004
Location: Florida
Distribution: Gentoo
Posts: 148

Rep: Reputation: 15
grep was already mentioned, but if you're looking for the file with the 'PS1=' line in it (which I was not sure if you are or not), try /etc/profile and ~/.bash_profile -- one or the other should contain the PS1= line.
 
Old 11-15-2004, 04:46 AM   #6
naps
Member
 
Registered: Aug 2003
Distribution: 10.3
Posts: 39

Original Poster
Rep: Reputation: 15
Wink

Quote:
Originally posted by Adrohak
<snip>one or the other should contain the PS1= line.
I guess knowing where to look is the answer.

Naps
 
  


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
How to find files containing specific text? SurfTurtle Linux - Newbie 7 01-05-2008 05:57 AM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 07:15 PM
du on specific files from find command (use xargs?) fireman949 Linux - Software 2 07-10-2005 01:42 AM
Shell script - how to show a specific line of a text file davi_cabral Linux - Software 3 09-28-2004 01:39 PM
find and replace in files from command line dexter_modem Linux - General 4 06-10-2003 11:27 AM


All times are GMT -5. The time now is 06:19 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration