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.
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.
$cat > [file_name]
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
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 "^") |
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.
$cat [file_name]
it will show the content of file1.
$cat file1
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.
$cat [file_name1] > [file_name2]
it transfer the text of 'file1' into 'file2'.
$cat file1 > file2
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.
$cat [file_name1] >> [file_filename2]
$cat file1 >> file2