Professional Documents
Culture Documents
1.Display all the input that are typed in the console immediately using cat command
[eeeb122@sel-48 ~]$ cat > s1
abcde
123
eee
345
cse
^Z
[8]+ Stopped cat > s1
[eeeb122@sel-48 ~]$ cat < s1
abcde
123
eee
345
cse
OUTPUT:
[eeeb122@sel-48 ~]$ cat > college
SSN college of engg.
^Z
[9]+ Stopped cat > college
^Z
[10]+ Stopped cat > country
3. Write the output of ls in a file and count the number of lines in that file
OUTPUT:
[eeeb122@sel-48 ~]$ ls
college Downloads f1 fn2 Music r2 Templates
country Ex 2 output.pdf fags fn3 Pictures run1 Videos
Desktop ex 3. fd fn4 Public ssn
Documents ex 3.pdf fn1 gafs r1 SSN
4. Concatenate College and country files information into a single file called
"colleges_and_country"
OUTPUT:
[eeeb122@sel-48~]$cat college country>> colleges_and_country
5.Append some more college information in college file and display the contents of
college file using input direction operator
OUTPUT:
[eeeb122@sel-48 ~]$ cat >> college
St.Joseph
^Z
[11]+ Stopped cat >> college
[eeeb122@sel-48 ~]$ ls
college Documents ex 3.pdf fn1 gafs r1 SSN
colleges_and_country Downloads f1 fn2 Music r2 Templates country Ex 2
output.pdf fags fn3 Pictures run1
Videos Desktop ex 3. fd fn4 Public ssn
eeeb122 eeeb122
# users=2
5. Create a file named "big_file" which contains more than 50 lines. Show the
difference between the commands "cat big_file" and "cat big_file | more"
OUTPUT:
[eeeb122@sel-48 ~]$ cat > big_file
a
g
h
d
f
s
d
f
9(more than 50)
^Z
[12]+ Stopped cat > big_file
run
^Z
[14]+ Stopped cat > a1
run
^Z
[15]+ Stopped cat > a2
run
^Z
[16]+ Stopped cat > a3
2. Show that the given two files are differed by giving the message " Files are differ"
OUTPUT:
3. Show that the given two files are same in case insensitive manner
OUTPUT:
[eeeb122@sel-48 ~]$
4. Compare the given two files and show they are differ or not
OUTPUT:
[eeeb122@sel-48 ~]$ diff a1 a2
1c1
< ABCD
---
> abcd
3c3,4
< EEE
---
> eee
>
OUTPUT:
[eeeb122@sel-48 ~]$
7. Compare and show how each byte in the given two files differ among
themselves
OUTPUT:
5 12 145
6 61 12
7 62 61
8 63 62
9 64 63
10 65 64
11 12 65
12 145 12
15 12 145
18 162 12
19 165 162
20 156 165
21 12 156
cmp: EOF on a2
a2:abcd
a3:abcde
9. Search the file for the given pattern and print its count
OUTPUT:
10.Search the file and print the non pattern matching lines
OUTPUT:
12345
eee
11. Search the file and count the number of non pattern matching lines
OUTPUT:
[eeeb122@sel-48 ~]$ grep -v bcd a2 | wc -l
OUTPUT:
[eeeb122@sel-48 ~]$ grep -i BCD a2
abcd
13.Create a file which contains the patterns to be searched. Search the pattern
file with file1
OUTPUT:
[eeeb122@sel-48 ~]$ cat > pattern
abc
eee
^Z
[16]+ Stopped cat > pattern
[eeeb122@sel-48 ~]$ grep f pattern file1
eee
14.What is the expansion for grep?
Global Regular Expression Print