Commands: $ logname  to check present working user. User2 $ clear



Download 122.5 Kb.
Page15/17
Date25.10.2023
Size122.5 Kb.
#62396
1   ...   9   10   11   12   13   14   15   16   17
Unix Commands
Translation command (tr)
This ‘tr’ command is used to replace the character.
Syn: $ tr “old char” “new char” < [file name]
tr command replace the “old char” with “new char”. It will display the replaced output but it will not shoe any affect on the original file.
Ex: $ tr “a” “z” < file1
Here in file1 data the char “a” is replaced with char “z” and displayed on output screen.
To redirect the replaced output to another file use redirection operator. So we can store the replaced output
Ex: $ tr “a” “z” < file1 > filex  To redirect the replaced output to filex
Silently redirects the replaced output to filex
tee” command
It works along with pipe symbol. It acts as right redirection operator ‘>’ but it displays the output on the screen as well as send to output file.
Ex:
$ cat < file1 | tee filex
$ date | tee filex
$ ls –l | tee filex
$ who | tee filex
$ tr “a” “z” < file1 | tee filex
Grep command: pattern searching
Grep command is used to search a particular pattern from the files
Syn:
$ grep “searching pattern” [file name]
Grep command displays the lines in which searching pattern is found.
$ grep –n “searching pattern” [file name]
Displays the lines along with line numbers in which searching pattern is found.
$ grep –v “searching pattern” [file name]
Displays the lines in which searching pattern is not found i.e., expect the lines containing the pattern will be displayed.
$ grep –vn “searching pattern” [file name]
Displays the lines along with line numbers in which searching pattern is not found
$ grep –c “searching pattern” [file name]
It displays the number of lines on which pattern is found
$ grep –i “searching pattern” [file name]
Grep command is case sensitive so to ignore the case sensitive ‘–i’ option is used.

Download 122.5 Kb.

Share with your friends:
1   ...   9   10   11   12   13   14   15   16   17




The database is protected by copyright ©ininet.org 2024
send message

    Main page