cat - Unix, Linux Command


Advertisements


NAME

cat - Concatenate and print the content of files.

SYNOPSIS

cat [Options] [File]...

DESCRIPTION

Cat command concatenate FILE(s), or standard input, to standard output. With no FILE, or when FILE is -, it reads standard input.

OPTIONS

TagDescription
-A, --show-allequivalent to -vET
-b, --number-nonblanknumber nonblank output lines
-eequivalent to -vE
-E, --show-endsdisplay $ at end of each line
-n, --numbernumber all output lines
-s, --squeeze-blanknever more than one single blank line
-tequivalent to -vT
-T,--show-tabsdisplay TAB characters as ^I
-u(ignored)
-v, --show-nonprintinguse ^ and M- notation, except for LFD and TAB. display this help and exit
--helpdisplay this help and exit
--versionoutput version information and exit

EXAMPLES

Create two sample files

#sample.txt
This is a sample text file
#sample1.txt
This is a another sample text file

To display content of a file.

$ cat sample.txt
This is a sample text file

To display content of all txt files.

$ cat *.txt
This is a another sample text file
This is a sample text file

To concatenate two files.

$ cat sample.txt sample1.txt > sample2.txt
$ cat sample2.txt
This is a sample text file
This is a another sample text file

To put content of a file in a variable.

$ variable_content = 'cat sample.txt'


Advertisements