LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-10-2008, 10:53 PM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 436

Rep: Reputation: 33
Find command again.


I want to find the string 'abc' (no quotes) located in any directory or file on the machine.

I've tried: egrep -rl 'abc' /* 2>/dev/null
but this didn't work.

I'm I doing this correctly?

Thanks, Newbi again...
 
Old 11-10-2008, 11:39 PM   #2
nigelc
Member
 
Registered: Oct 2004
Location: Sydney, Australia
Distribution: Mageia 4
Posts: 340
Blog Entries: 4

Rep: Reputation: 63
I tried this, but it seems to be stuck in the /dev directory. if you miss out the "2>/dev/null" just sit & watch it.
 
Old 11-11-2008, 01:33 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Are you looking for 'abc' in a dirname or filename, or do you mean in the contents of a file?

For dirnames & filenames
1. find / -name '*abc*' -print 2>/dev/null

If you want only one of dirs or files, use the -type switch eg

2. find / -type f -name '*abc*' -print 2>/dev/null
3. find / -type d -name '*abc*' -print 2>/dev/null

file contents

4. grep -rHn abc *
 
  


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/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 06:30 PM
find and mv command nirmit Linux - Newbie 2 06-27-2008 06:45 AM
find command brazilian_user Linux - General 1 09-12-2006 10:50 AM
find command jch02140 Linux - Newbie 2 07-19-2005 01:21 AM
Find Command chrisk5527 Linux - General 3 04-19-2003 07:26 PM


All times are GMT -5. The time now is 04:02 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