Textprocessingutilities Awk Command: Used To Print The Output Based On Our Requirement
Textprocessingutilities Awk Command: Used To Print The Output Based On Our Requirement
Initial Input:
Output :
Task: Displays 2nd field and 4thfield of lines whose 2nd field is Neeraj
Output:
Output:
Output:
diff command: It displays difference between 2 files and the changes needed to be done to
make both the files same.
Output:
Output:
Output:
Explanation: 0am: Add mth column in file2.
Comm command: Compares 2 sorted files and displays the result in output.
Output:
Explanation: First column contains names only in file1, 2nd column contains names only
in file2 and 3rd column contains names common to both file 1 and file 2.
Output:
Cmp command: Compares 2 files and writes the result to standard output
Output:
Output:
tr command: It takes as parameters two sets of characters or strings, and replaces
occurrences of the characters in the first set with the corresponding elements from
the other set.
Syntax: tr options exp1 exp2 <filename //filename is optional
Example1: tr ‘e’ ‘a’ <marks
Output:
Output:
Example 3: tr –d ‘ee’<filename
Output:
Output:
Output:
Explanation: Output of cat test1 is displayed and that output is copied into
test2.
Example 2: cat test1|tee –a test2
Output:
Output:
Example:sort –r Neeraj
Output:
Syntax: nl filename
Example: nl Neeraj
Output:
Output:
Example2: uniq-D Neeraj
Output:Prints field of 1st and 3rd of each line from the file.
Example2: cut –d”c” –f1,3 neeraj
Output: Prints field of 1st and 3rd of each line from the file with c as
delimiter.
Output:prints characters from third to sixth of each line from the file.
Paste: Create new file by gluying together fields or columns from 2 or more files.
Output:
Output:
Output: Prints the number of lines containing the given word Neeraj
Output: Prints lines except the lines the lines containing Neeraj
Example4:grep –n Neeraj marks
Example: grep ‘1
>2
>3’ marks
Output:
egrep: To search for 2 or more strings simultaneous but in a single line only.
Output: