1. Search
GREP-LR YHB./
Indicates that all files in the current directory, including sub-files, are searched for the YHB character, and the file name is printed. If there is no-l, the searched rows will be printed out.
2. Display the number of rows
NL test.txt
The line number of a non-blank line is displayed by default.
Nl-b a Test.txt
Displays the line numbers for all lines, including blank lines.
NL Test.txt | Wc-l
Count Non-empty rows
3.sed command
- Select text:-N does not display the contents of the default buffer,-P forces the contents of the buffer to appear sed-n ' 1,3p ' students.txt #只显示1 the line
- Replacement text: [ADDRESS1[,ADDRESS2]] s/pattern/replacemen/[flag] sed ' 1,3 s/e/e/g ' students.txt #替换1 all lowercase e in the line is capital letter E
- Delete text: [address1[,address2]] d sed ' 1,4 d ' students.txt #删除1到4行 sed '/^$/d ' students.txt #删除空行
- Insert text: [Address1] I string sed ' 2 i 200200109 Tom ' Students.txt #在第二行插入200200109 Tom Records.
Common shell commands