Linux/Unix Tutorial for Beginners - cat command , grep command

Veröffentlicht am: 25 Mai 2019
auf dem Kanal: Coding GuruJi
243
8

This tutorial comprises of brief description with real time output of the cat command and grep command
Th cat command is used for viewing contents of a file
The grep command is used for searching keyword/s in files.


The various options/combinations of cat commands are as follows:-
1.) cat filename -- displays contents of a file
2.) cat file1 file2 -- displays contents of multiple files
3.) cat file1 greater_than_sign file2 -- copy contents of file 1 and overwrite it on top of file2
4.) cat -n filename -- displays the contents of the files by appending line numbers
5.) cat file1 greater_than_signgreater_than_sign file2 -- append contents of file 1 to that of file2.
6.) tac file -- displays the contents of file in a reverse order
7.) cat greater_than_sign filename -- creates a file with the name provided in the command and then allows to enter contents for the file in the immediate next line using the same command.
8.) cat filename | more -- Allows to display contents of a huge file in a page by page format and scrolling only happens down the page(unidirectional), this is a bit slower than the less option.
9.) cat filename | less -- Allows to display contenst of a huge file where the user can scroll both up and down as required.
10.) cat file1 file2 file3 greater_than_sign file4 -- Allows contents of multiple files to be redirected to a particular file.

The various options/combinations of grep command are as follows:-

1.) grep keyword path_of_file -- displays the lines of the file at places where the keyword is available.
2.) grep -v keyword path_of_file -- displays the lines of the files at places where the keyword is NOT available.
3.) command output | grep keyword -- searches for a keyword in lines of output of a command it is used with
Ex- ps -ef | grep java
4.) grep -r keyword path_to_be searched -- searches for a keyword recursively within the provided path and doesn't include any sym-links.
5.) grep -R keyword path_to_be searched -- searches for a keyword recursively within the provided path and includes any sym-links.
6.) grep -i path_of_file --searches for a keyword irrespective of the case of the keyword.
7.)grep -n path_of_file -- this option includes line numbers to output of grep command
8.)grep -w keyword path_of_file -- to match for words of the file where the keyword is same as the matched wor.
9.) grep -c keyword path_of_file -- this shows the count of matching lines at the provided path_of_file
10.) grep -E 'keyword1|keyword2' path_of file -- this option is used for searching multiple files.


Please subscribe and join my channel at Telegram for more information:-
https://t.me/Coding_Guruji


Auf dieser Seite können Sie das Online-Video Linux/Unix Tutorial for Beginners - cat command , grep command mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Coding GuruJi 25 Mai 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 243 Mal angesehen und es wurde von 8 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!