LINUX
CAT COMMAND
cat command allows us to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files.
Syntax of cat command
$ cat [option] [files]
$ cat > file.txt
$ cat linux.txt
this command show the content of file linux.
$ cat linux.txt aman.txt
this command show the content of files linux and aman simultaneously.
$ cat -b aman.txt
this command show the line number of the every content line of the file having non blank line. This command option skip the blank line of the file if have.
$ cat -n aman.txt
this command added the line number of the every content line of the file having non blank line as well as blank line. This command option skip the blank line of the file if have.
$ cat aman.txt >> linux.txt
This command add the all content of file aman.txt into the end of the file linux.txt.
The content of the both files will be saved no one be over witted.
When you run the command the content of aman.txt moves into the linux.txt
The files look like that
$ cat aman.txt > linux.txt
Syntax of cat command
$ cat [option] [files]
1. For creating files
$ cat > file.txt
2. View the content of files
$ cat linux.txt
this command show the content of file linux.
3. View the content of more than two files
$ cat linux.txt aman.txt
this command show the content of files linux and aman simultaneously.
4. Showing the line numbers
$ cat -b aman.txt
this command show the line number of the every content line of the file having non blank line. This command option skip the blank line of the file if have.
$ cat -n aman.txt
this command added the line number of the every content line of the file having non blank line as well as blank line. This command option skip the blank line of the file if have.
5. move the content of one file to another file.
$ cat aman.txt >> linux.txt
This command add the all content of file aman.txt into the end of the file linux.txt.
The content of the both files will be saved no one be over witted.
File 1 : aman.txt
File 2 : linux.txt
When you run the command the content of aman.txt moves into the linux.txt
The files look like that
6. over- write the content of files.
$ cat aman.txt > linux.txt
This command over - write the content of file linux.txt by the content of file aman.txt.
Mean the content of linux file will be removed and new content of the file aman.txt will be added at the last of linux.txt.
7. Move the content of two or more files into a Single file.
7. Move the content of two or more files into a Single file.
$ cat test1.txt test2.txt > result.txt
This command will create a new file result.txt and the content of files test1.txt and test2.txt will moved into the new file result.txt.
Your feedback is very important for us :)

Post a Comment
0 Comments