How to use the cat command in linux
This article is about how to use the cat command in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Note: after the awk command, there are not many complex commands, all basic commands.
Description:
Cat, the abbreviation of the word concatenate, outputs the contents of the file to stdout. When associated with the redirection operator (> or
When used in combination, it is generally used to connect multiple files.
Usage:
1. $cat file1 file2 file3
two。 It can be read not only from the file and spliced, but also from the standard input stream.
For example: $echo 'some content' | cat-file.txt
Explanation: here-represents the temporary file of 'some content', that is, the input stream
Example:
1. $cat cat.txt
Printed all the contents of cat.txt
2.$cat cat.txt | less
Check cat.txt, one page and one screen after joining less, which will be described in the less,more command later.
3.$cat-n cat.txt
Mark the line number before each line, including blank lines
4.$cat-b cat.txt
Mark the line number before a non-blank line
Interpretation-- help
Usage: cat [option]. [file].
Output [file] or standard input combination to standard output.
-A,-- show-all equals-vET
-b,-- number-nonblank to the non-empty outgoing line number
-e equals-vE
-E,-- show-ends displays "$" at the end of each line
-n,-- number numbers all lines of the output
-s,-- squeeze-blank does not output multiple blank lines
-t is equivalent to-vT
-T,-- show-tabs displays tabbed characters as ^ I.
-u (ignored)
-v,-- show-nonprinting uses ^ and M-references, except for LFD and TAB
-- help displays this help and exits
-- version displays version information and exits
If no file is specified, or if the file is "-", it is read from standard input.
Example:
Cat f-g outputs the content of f first, then the content of standard input, and finally the content of g.
Cat copies the contents of standard input to standard output.
Interpretation:
1. Cat-s file.txt
If there is a file that has this format:
Line1
# blank line
Line2 file2
Use this command.
Cat is more combined with other commands, and there is no complicated content of its own. If you are bored, try cat-A cat.txt and you will have unforgettable memories.
Related commands:
Cat's father-in-law is usually ordered by sed,tr.
Such as:
$cat file | sed's Compact OldUniverse G'
Display the file file and convert old to new without modifying the original file
Thank you for reading! This is the end of this article on "how to use cat commands in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!