Text processing cat more less head tail sort uniq grep cut jion sed awk
################################################
cat:concatenate files and print on the standard output display the contents of the file to the normal outputs (display)
-E: Displays the last character at the end
-N: Show line numbering
[Email protected] ~]# cat-n/etc/shells
1/bin/sh
2/bin/bash
3/sbin/nologin
4/bin/dash
5/bin/tcsh
6/bin/csh
[Email protected] ~]# cat-e/etc/shells
/bin/sh$
/bin/bash$
/sbin/nologin$
/bin/dash$
/bin/tcsh$
/bin/csh$
################################################
More less: multi-screen display
Head: Show the first few lines
Tail: Show the end of a few lines
Head: Show the first few lines
Tail: Show the following lines
-F: Append display, this command is more important
[Email protected] ~]# head-2/etc/shells
/bin/sh
/bin/bash
[Email protected] ~]# Tail-2/etc/shells
/bin/tcsh
/bin/csh
################################################
Sort: Sorting Ascending
-N: Sort by number
-R: Descending
-T: Field separator
-K: The same after sorting is displayed only once
-F: Sort ignoring character case
[Email protected]/]# Cat/tmp/t1.txt
1
11
2
3
4
5
6
21st
324
Default ASCII sort
[Email protected]/]# Sort/tmp/t1.txt
1
11
2
21st
3
324
4
5
6
ASCII Descending
[Email protected]/]# sort-r/tmp/t1.txt
6
5
4
324
3
21st
2
11
1
Number Descending
[Email protected]/]# Sort-nr/tmp/t1.txt
324
21st
11
6
5
4
3
2
1
Number Ascending
[Email protected]/]# sort-n/tmp/t1.txt
1
2
3
4
5
6
11
21st
324
################################################
Uniq: (omitted) reports adjacent duplicate rows
-C: Shows the number of rows in a file that repeats
-D: Show only duplicate rows
[Email protected]/]# Cat/tmp/t1.txt
1
2
3
1
2
2
45
45
[Email protected]/]# Uniq/tmp/t1.txt
1
2
3
1
2
45
[Email protected]/]# uniq-c/tmp/t1.txt
1 1
1 2
1 3
1 1
2 2
2 45
[Email protected]/]# uniq-d/tmp/t1.txt
2
45
################################################
Wc:word number of line words in count statistics file bytes
-L: Line
-M: Words
-C: bytes
[Email protected]/]# Wc/tmp/t1.txt
8 8 18/tmp/t1.txt
################################################
Character processing commands
TR: Character conversion or deletion character
-D: Remove all characters that appear in the character set
[[Email protected]/]# TR ' AB ' AB '
Ab
Ab
Abc
Abc
Abc
Abc
[[email protected]/]# tr-d ' AB '
Abcd
Cd
Adbc
dc
Aabb
################################################
Cut:remove sections from the all line of files display file specified field
Cut: Show file specified field
-D: Specify field separator, default space
-F: Specify the fields to display
-F 1,3-f 1-3
[Email protected]/]# cut-d:-f1/etc/passwd | Tail-1
Jameszhan
################################################
grep Follow-up explanation
################################################
################################################
Jion less Use Skip
################################################
Sed follow-up explanation
################################################
awk Follow-up explanation
################################################
Linux Basic article 07,linux text processing cat more less head tail sort uniq grep cut jion sed awk