cat
- print and concatenate files.
Syntax
Description
Concatenate FILE(s), or standard input, to standard output.
Option |
Description |
-n –number |
Number all output lines including blank lines |
Example
print contents of a file to standard output
print contents of a file to standard output with line number.
concatenate files into a single file
concatenate files and append to file3
clean up the contents in file1
Pass a multi-line string to a file
You can sometimes see cat command use together with heredoc
1 2 3 4
| cat <<EOF > print.sh #!/bin/bash echo "Hello World" EOF
|
concatenate and print files in reverse order
tac
is the reverse of cat
.
Reference