grep (is beautiful)
this line has tacos
this line has tacos
this line dosen't
more tacos
more tacos
- Search through stdin for things
- Sends to stdout lines matched lines
$ grep tacos
this line has tacos
this line has tacos
this line dosen't
more tacos
more tacos
- You can do the same in awk with
$ awk '/tacos/{print $0}'
Ex1. $ grep B2
Ex2. $ grep A4
Ex3.$ grep C3
- -B prints lines before match
- -A prints lines after each match
- -C prints the lines before and after
- -i case insenstive search
- -v prints lines with no match
- -c prints just number of matches
- --color highlights matches
- Fancy regular expressions: -E
- Example: Match IP range from 172.22.21.1 to 172.22.21.35:
Example:
$ grep E '172\.22\.21\.([19]|( 1[09]| 2[09]| 3[05])) ' hosts.txt
xargs (to the rescue)
Example: run cvs update in all subfolders:
find . type d | xargs i t sh c \ 'cd {};cvs update'
xargs (to the rescue)
Example: run cvs update in all subfolders:
find . type d | xargs i t sh c \ 'cd {};cvs update'
0 comments:
Post a Comment