LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-21-2005, 07:07 PM   #1
slackb0t
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264

Rep: Reputation: 63
'man grep' caused my head to hurt


ok I just read the man pages for grep.. I am no further ahead than when I started.. could someone please explain in simple terms what it's use is and maybe a few examples of where you would use it... thanks in advance

ps I remember I copied a command from this form with grep in it to find files.. but I can't seem to locate it anymore.. like to search /etc for *.new files.. so I could update config files etc..
 
Old 04-21-2005, 07:35 PM   #2
xgreen
Member
 
Registered: Aug 2003
Distribution: Slackware,Arch
Posts: 389

Rep: Reputation: 30
you try this...
http://www.tldp.org/LDP/Bash-Beginne...ect_04_02.html
 
Old 04-21-2005, 09:53 PM   #3
slackb0t
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264

Original Poster
Rep: Reputation: 63
thanks... that guide helped but I still can't figure out how to find files.. from what I read grep only finds words or 'expressions' within a file.. I am thinking I need to look into the find command more..

but I bookmarked that site and learned a lot.. thank you again.. I am about to google to see if there is something similiar for the find command..
 
Old 04-21-2005, 09:59 PM   #4
cavalier
Member
 
Registered: Feb 2005
Location: Denver, CO
Distribution: Slack 12, tweaked just so (though I'm also a fan of Ubuntu)
Posts: 198
Blog Entries: 1

Rep: Reputation: 30
Let me give you the single most useful structure for "find":
Code:
find / -name bash
This command says find, starting at the root directory, a file named bash. Try it. It should at least find /bin/bash

I use some variant on this all the time to find files that aren't on my path.

Another, similar command, that I truly adore is "which":
Code:
which bash
This'll do the same thing, but it'll only work on files that are in your path, so you can find executables that are on your path quickly.
 
Old 04-21-2005, 10:06 PM   #5
xgreen
Member
 
Registered: Aug 2003
Distribution: Slackware,Arch
Posts: 389

Rep: Reputation: 30
ok this is how i search files, for example mynotes.txt

code :

find / -name *notes*

find = find cmd
/ = start search from root. if you want to serch within your home dir then find /home/xxx/ -name *notes*
*notes* = search any file name contains "notes"


now for the grep things..for example in /etc you to list out lilo.conf
code :

ls -l /etc | grep lilo

ls- l = you know right
/etc = path
| = this is called pipe means the output of ls -l /etc/ is directed to grep
grep = filter out expression given (in this case is lilo) from ls -l /etc
 
Old 04-21-2005, 10:06 PM   #6
slackb0t
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264

Original Poster
Rep: Reputation: 63
Quote:
I use some variant on this all the time to find files that aren't on my path.

This'll do the same thing, but it'll only work on files that are in your path, so you can find executables that are on your path quickly.
Thank you.. I have tried your examples... but could you explain to me what you mean by "on my path" .. I have seen this expression used before but was unclear as to it's meaning..

edit:
I have been playing around with the examples you guys have given me.. I think I have it worked out.. just one to clarify something

ls -l /etc | grep lilo and find /etc -name '*lilo*' should give you the same results

or

ls -l /home/x/* | grep burning is the same as find /home/x/ -name '*burning*'

is there one that is more appropriate? I am thinking that using find is better when there are subdirectories and ls is good if you know the directory?

Last edited by slackb0t; 04-21-2005 at 10:24 PM.
 
Old 04-21-2005, 10:23 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
$PATH is an environment variable ... it contains a colon-
separated list of directories in which the shell will look
for executables. Some things may not be "in your path",
e.g. if you're logged in as a normal user you won't have
iptables in your path ...


Cheers,
Tink
 
Old 04-22-2005, 03:44 AM   #8
mcd
Member
 
Registered: Aug 2003
Location: Denver, CO
Distribution: CentOS, Debian
Posts: 825

Rep: Reputation: 33
you can add things to you path in the ~/.bashrc file, among other places
 
Old 04-22-2005, 06:07 PM   #9
Genesee
Member
 
Registered: Dec 2002
Distribution: Slackware
Posts: 927

Rep: Reputation: 30
when you're done with those, another command to check out is "locate"

 
  


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
Man pages error, Dual Locales caused it? Debian Sid. bence8810 Debian 3 03-19-2006 01:02 PM
grep -l ->man question darkleaf Linux - Software 2 04-08-2005 11:20 AM
Multi-monitor Issues on RH9, Geforce 4 Ti Dual Head + TNT2 Single Head the letter b Linux - Newbie 3 12-04-2004 11:23 PM
Fonts in Galeon hurt my head. Can I change them? jcksrobbins Linux - Software 1 09-29-2003 11:11 PM
x86 Solaris 9 XSun and Matrox G550 dual-head... one head down, one to go. finegan Solaris / OpenSolaris 4 03-11-2003 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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