cat (short for “concatenate)
cat [OPTION] [FILE]…
To view content of file
To view content of multiple files
cat file1.txt file2.txt
To create file (instead of nano)
Then press ctrl+d to exit
cat file1.txt | more
cat file2.txt | less
Display along with numbers of line
cat -n filename
Display $ at the End of every line with -e option
cat -e test
Multiple Files at Once(semi colons required)
cat file; cat file1; cat file2
cat file > file1
existing contents of filr1 will be overwritten by contents of file file.
Standard Output with Redirection Operator)
cat file >> file1
contents of file file will be appended at the end of file1 file.
Redirecting Standard Input with Redirection Operator
cat < file2
Displays the file2 information on the terminal
Redirecting Multiple Files Contain in a Single File
cat file file1 file2 > file3
Sorting Contents of Multiple Files in a Single File
cat file file1 file2 file3 | sort > file4,
all the contents piped and sort and results will be an new file
touch command only to create a file
later you have to use vim or nano to edit.
Nano file editor
sudo nano newfile.conf
#press ctrl+x and then y save changes.
sudo apt-get install vim
Press i insert or edit,
press Esc and then :wq to save and exit.
e opens file
:Wq to save changes and exit
:q! Exit without changes
0 to mive cursor to the first line