1.1.
usage of the Cut command in the shell
The first usage is similar to awk, as shown in awk below :
Cat/etc/passwd|awk-f: ' {print $1,$5} '
Cut-d: The colon after-F 1,5/etc/passwd/-d indicates the delimiter between the fields, and-f indicates which fields after the de-delimiter
You can also use the cut command to cut partial characters with a scalar number of characters, which is implemented with the- C option and cannot coexist with the- d option.
Cut-c 1-4/etc/passwd # takes the first 1-4 characters of each line
1.2.
Return line break
line break in Windows system is CRLF, English is carriage-return(enter \ r) Line-free (line break \ n ). So, when a shell script written by the Windows system runs on Linux , a transformation is required. Otherwise it will report a grammatical error "syntax error near unexpected token"
1.3.
double quotes after Echo
Without double quotes, special variables are escaped with special symbols in the output variable, such as:
(1) for I in 2 \*;d o echo $i;d one;
(2) for I in 2 \*;d o echo "$i";d one;
The first statement does not display an asterisk, which represents all files in the current directory. Instead, you should use the second usage.
Shell Common Command Summary (iii)