if [ 條件 ];thenxxx
fi
if [ 條件 ]thenxxx
fi
case $變量 in"p1")xxx;;"p2")xxx;;*)xxx;;
for(( 初始值;循環條件:變量控制 ))doxxxdonefor((變量 in v1 v2 v3))doxxxdone
while [ 條件 ]doxxxdone
8. 增刪改查 8.1 cut
-sh-4.2$ cut --help
Usage: cut OPTION... [FILE]...
Print selected parts of lines from each FILE to standard output.Mandatory arguments to long options are mandatory for short options too.-b, --bytes=LIST select only these bytes-c, --characters=LIST select only these characters-d, --delimiter=DELIM use DELIM instead of TAB for field delimiter-f, --fields=LIST select only these fields; also print any linethat contains no delimiter character, unlessthe -s option is specified-n with -b: don't split multibyte characters--complement complement the set of selected bytes, charactersor fields-s, --only-delimited do not print lines not containing delimiters--output-delimiter=STRING use STRING as the output delimiterthe default is to use the input delimiter--help display this help and exit--version output version information and exitUse one, and only one of -b, -c or -f. Each LIST is made up of one
range, or many ranges separated by commas. Selected input is written
in the same order that it is read, and is written exactly once.
Each range is one of:N N'th byte, character or field, counted from 1N- from N'th byte, character or field, to end of lineN-M from N'th to M'th (included) byte, character or field-M from first to M'th (included) byte, character or fieldWith no FILE, or when FILE is -, read standard input.GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'cut invocation'
8.2 sed sed 一次處理一行數據,處理時把當前處理的行存儲在臨時緩沖區,sed 開始處理緩沖區中的內容,處理完了輸出
-sh-4.2$ sed --help
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...-n, --quiet, --silentsuppress automatic printing of pattern space-e script, --expression=scriptadd the script to the commands to be executed-f script-file, --file=script-fileadd the contents of script-file to the commands to be executed--follow-symlinksfollow symlinks when processing in place-i[SUFFIX], --in-place[=SUFFIX]edit files in place (makes backup if SUFFIX supplied)-c, --copyuse copy instead of rename when shuffling files in -i mode-b, --binarydoes nothing; for compatibility with WIN32/CYGWIN/MSDOS/EMX (open files in binary mode (CR+LFs are not treated specially))-l N, --line-length=Nspecify the desired line-wrap length for the `l' command--posixdisable all GNU extensions.-r, --regexp-extendeduse extended regular expressions in the script.-s, --separateconsider files as separate rather than as a single continuouslong stream.-u, --unbufferedload minimal amounts of data from the input files and flushthe output buffers more often-z, --null-dataseparate lines by NUL characters--helpdisplay this help and exit--versionoutput version information and exit