-
cut
-
use case 1:
cut -c LIST [file|stdio]
, for example,
cut -c 1-3[,5-] *.txt
#print characters from 1st to 3rd character column to standard output -
use case 2:
cut -b LIST [file|stdio]
-
use case 3:
cut -d DELIMITER -f LIST [-s] [file|stdio]
, for example,
ls -l | cut -d " " -f 2-
#print fields from 2nd to the end of each line in file
grep
grep [options]… PATTERN [FILE]…
Purpose
- search and print lines matching a pattern from file or stdin
Core Points
(1) two variant program:
egrep #same as grep -E, interpret PATTERN as an extended regular expression (ERE)
fgrep #same as grep -F, interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched(2)useful options:
-G #as default basic regexp
-i|-y #ignore-case
-l|-L #suppress normal output but only output file name
–exclude=GLOB(such wildcards as *,?.etc) #