cat command in Linux

cat is short for Concatenate. cat is used to create a file and display, appending the contents of a file.

Usage: cat [OPTION]… [FILE]…
Concatenate FILE(s), or standard input, to standard output.

-A, --show-all equivalent to -vET
-b, --number-nonblank number nonempty output lines
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank suppress repeated empty output lines
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version output version information and exit

With no FILE, or when FILE is -, read standard input.

Examples:

Create a file using cat

$cat > test1.txt
Welcome to k2schools

Press ctrl+d to save the file.

To display the contents of the file

$cat < test1.txt or $cat test1.txt

Append the data to existing file.

$cat >> test1.txt
Visit again k2schools.com

Press ctrl+d to save the file.

To display the file with line numbers

$cat -n test1.txt

cat command in Linux

CheapSexCams
You can leave a response, or trackback from your own site.

Leave a Reply

Powered by k2schools
%d bloggers like this: