Operating Systems > Linux and UNIX
Question about FAT32 and RedHat Linux
Baikonur:
What does "grep" mean and how is it used?
Stryker:
quote:Originally posted by Xenix God:
What does "grep" mean and how is it used?
--- End quote ---
easy, lets say i have some files in a directory:
cparty1 cparty2 cparty3 cb1 cb2 cb3
i only want to view the ones with party, so
ls | grep party
i can't think of how to explain it without using an example.
Baikonur:
Interesting Unixologism.
flap:
grep searches through specific files or standard input and prints any lines that match a particular pattern. It uses regular expressions so the pattern matching is very powerful.
A simple example:
grep '^fish[^ ]' ./*
will search through all files in the current directory and output any lines that begin with "fish", followed by any character other than a space.
Faust:
Or for example if I want to find all mp3 files on my hard drive to convert them to ogg files I just:
ls -R /home | grep mp3
ls lists all the files on my home dir with -R.
The pipe redirects that output (my list of files) to grep.
Grep only shows me the ones with the phrase "mp3" in them, so I get list of files which are mp3s.
Or another example:
cat ~/telephonenumbers.txt | grep Fred
Fred Bloggs 60 123 456 789
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version