basic and common shell commands

来源:互联网 发布:科比0506常规赛数据 编辑:程序博客网 时间:2024/05/20 19:15
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) #