UNIX TUTORIALS - Unix - Pipes & Filters
Unix - Pipes & Filters
ADVERTISEMENTS
The grep Command:
Option | Description |
---|---|
-v | Print all lines that do not match pattern. |
-n | Print the matched line and its line number. |
-l | Print only the names of files with matching lines (letter "l") |
-c | Print only the count of matching lines. |
-i | Match either upper- or lowercase. |
ADVERTISEMENTS
The sort Command:
Option | Description |
---|---|
-n | Sort numerically (example: 10 will sort after 2), ignore blanks and tabs. |
-r | Reverse the order of sort. |
-f | Sort upper- and lowercase together. |
+x | Ignore first x fields when sorting. |
ADVERTISEMENTS
The grep Command:
$grep pattern file(s)
$ls -l | grep "Aug" -rw-rw-rw- 1 john doc 11008 Aug 6 14:10 ch02 -rw-rw-rw- 1 john doc 8515 Aug 6 15:30 ch07 -rw-rw-r-- 1 john doc 2488 Aug 15 10:51 intro -rw-rw-r-- 1 carol doc 1605 Aug 23 07:35 macros $
$ls -l | grep -i "carol.*aug" -rw-rw-r-- 1 carol doc 1605 Aug 23 07:35 macros $The sort Command:
$sort food Afghani Cuisine Bangkok Wok Big Apple Deli Isle of Java Mandalay Sushi and Sashimi Sweet Tooth Tio Pepe's Peppers $
$ls -l | grep "Aug" | sort +4n -rw-rw-r-- 1 carol doc 1605 Aug 23 07:35 macros -rw-rw-r-- 1 john doc 2488 Aug 15 10:51 intro -rw-rw-rw- 1 john doc 8515 Aug 6 15:30 ch07 -rw-rw-rw- 1 john doc 11008 Aug 6 14:10 ch02 $The pg and more Commands:
$ls -l | grep "Aug" | sort +4n | more -rw-rw-r-- 1 carol doc 1605 Aug 23 07:35 macros -rw-rw-r-- 1 john doc 2488 Aug 15 10:51 intro -rw-rw-rw- 1 john doc 8515 Aug 6 15:30 ch07 -rw-rw-r-- 1 john doc 14827 Aug 9 12:40 ch03 . . . -rw-rw-rw- 1 john doc 16867 Aug 6 15:56 ch05 --More--(74%)