December 1999
Beginner
528 pages
11h 10m
English
If we want to use grep to get information from our system, this is easily accomplished from what we have just learnt. In these examples, we’ll be using the pipe command, i.e. that the bar sign (|) takes the output from the left of the bar and uses it for input for the command on the right.
If you want to search a directory for directory listings only we can do this:
$ ls -l | grep '^d'
or search a directory and don’t include any directories:
$ ls -l | grep '^[^d]'
If we want to search for directories that have executable files set by group and other:
$ ls -l | grep '^d.....x..x'
$ grep "louise" /etc/passwd louise:lxAL6GW9G.ZyY:501:501:Accounts Sect 1C:/home/accts/louise: ...Read now
Unlock full access