CAT Command

cat command is used to create a file,also used to display the content of created file or existing file,it is used to move the content one file to another file,cat command is another used for append text from one file to another file,cat command is one command used for many purpose the following list of used of cat command with example.

 Creating a file

cat command is used to creating a new file,to make a new file in linux uisng cat command,the following syntax and example of creating file usign cat command.

Syntax

$cat > [file_name]

Example

after executin the command you just need to provide text for the file.then after entering the text press ctrl + d to get back the prompt.


$cat > file1
							

Options

Sr.No

Options

Description

01

 -e

Display control and non printing character,excepts line feeds and tab and display $ at the end of each line.

02

 -E

display $ at the end of each line.

03

 -n

number all output lines.

04

 -t

display control and nonprinting characters except linefeeds.

05

 -T

display tab characters.(as "^")

 Display Content of File

cat command is also used to display content of file ,it will display all content in the linux terminal usig cat command,in this option you can not used any option only write command $cat and your file it will display all file content the following syntax and example of cat command.

Syntax

$cat [file_name]

Example

it will show the content of file1.


$cat file1
							

 Transfering the Content From one File to another

cat also used to move one file content to another file uisng this option ,you can write after write command put file1 > file2 the following syntax and example of cat command.

Syntax

$cat [file_name1] > [file_name2]

Example

it transfer the text of 'file1' into 'file2'.


 $cat file1 > file2
						

 Appending the Content of One File to another File

cat command can be also used to append text from one file to another or to merge the text from multiple files into single file.

Syntax

$cat [file_name1] >> [file_filename2]

Example


$cat file1 >> file2
					
Share Share on Facebook Share on Twitter Share on Google+ Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit