SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264
Rep:
'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..
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264
Original Poster
Rep:
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..
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
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264
Original Poster
Rep:
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?
$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 ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.