Commands learned in this section: cat(tac), more, less, head, tail, cut, sort, uniq, wc, tr
Skills learned in this section: Directory management
file management
datetime
View text
Split screen display
text processing
Summary of file management commands:
Directory management :
ls、cd、pwd、mkdir、rmdir、tree
File management :
touch、stat、file、rm、cp、mv、nano
Date Time :
date、clock、hwclock、cal
View text :
cat、tac、more、less、head、tail
cat : connect and display
-n: Number each line when displaying
-E: Display the line terminator for each line
( the tac command displays the text in reverse)
Split screen display :
more、less
more : support backward flipping, (disadvantage: flip to the end of the file and exit)
less : the same way as the man command (because less is used to open the file when using the man command)
head : view the first n lines ("n" defaults to 10)
tail : view the last n lines
-n: show the first few lines
tail -f: View the end of the file, do not exit, and wait for the new content appended to the file to be displayed;
Text processing :
cut、join、sed、awk
cut : cut the file
-d: Specify the field separator, the default is a space
-f: specify the fields to display
-f 1,3: display the first and third fields
-f 1-3: display the first to third fields
sort : text sorting (default is to sort in ascending ASCII order)
-n: sort by numerical size
-r: sort in descending ASCII order
-t: field separator
-k: which field is the key to sort by (sort -t: -k3 /etc/passwd)
-u: show the same line only once after sorting
-f: ignore character case when sorting
uniq : report which line has duplicate content (adjacent)
-c: show the number of times the line is repeated in the file
-d: show only duplicate lines
wc (word count) : text statistics (how many lines, words, and bytes can be counted in a file)
-l: only display the number of lines
-w: only display word count
-c: only display word bytes
-L: show how many characters are in the longest line
tr : character processing commands (transform or delete characters)
tr [OPTION]... SET1 [SET2]
-d: delete all characters that appear in the character set