Professional Documents
Culture Documents
Q1) Create the following file called as the geekstuff.txt and perform the following tasks.
Linux: Sysadmin ,Scripting etc.
Software
Hardware
Security (Firewall, Network, Online Security etc)
Storage
Cool gadgets and websites
Productivity (Too many technologies to explore, not much time available)
Website Design
Software Development.
Windows-Sysadmin, reboot etc.
viii. Write a command to print from fourth line till eight line.
OUTPUT:
b11029@linux-p6l1:~> sed -n '4,8p' geekstuff.txt
Security (Firewall, Network, Online Security etc)
Storage
Cool gadgets and websites
Productivity (Too many technologies to explore, not much time available)
Website Design
ix. Write a command to print the line only which matches the Pattern Sysadmin.
OUTPUT:
b11029@linux-p6l1:~> sed -n '/Sysadmin/p' geekstuff.txt
Linux: Sysadmin ,Scripting etc.
Windows-Sysadmin, reboot etc.
x. Write a command to print the 5th line which matches the pattern ‘Storage’ and next
two lines following ‘Storage’.
OUTPUT:
Method: Manually searching
b11029@linux-p6l1:~> sed -n -e '5p' -e '6,7p' geekstuff.txt
Storage
Cool gadgets and websites
Productivity (Too many technologies to explore, not much time available)
Other Method where we are matching pattern
b11029@linux-p6l1:~> sed -n -e '/Storage/p' -e '6,7p' geekstuff.txt
Storage
Cool gadgets and websites
Productivity (Too many technologies to explore, not much time available)
ii. Write a command to search all hr in Senoirs<rollno> file and give them a
Promotion as Manager.
OUTPUT:
b11029@linux-p6l1:~> sed 's/Hr/Manager/g' Seniors1029
2233| a.k.shukla | g.m | Sales |12/12/52|6000
9876|Jai Sharma| Director| Production|03/12/50|7000
5678|Sumit Chakraborty|d.g.m|Marketing|04/09/43|6000
2365|Barun Sengupta|Director|Personnel|05/11/47|7800
5423|n.k.sengupta|Chairman|Admin|08/30/56|5400
4356|Seema desai|Manager|Sales|12/12/83|4000
iii. Select all the persons present in the sales department, from Senoirs<roll_no> file
and store them in the sales file and store all the admins in a list file.
OUTPUT:
b11029@linux-p6l1:~> sed -n '/Sales/p' Seniors1029>Sales
b11029@linux-p6l1:~> cat Sales
2233| a.k.shukla | g.m | Sales |12/12/52|6000
4356|Seema desai|Hr|Sales|12/12/83|4000
iv. Write commands to change the empno present in the Seniors<rollno> all
empnos Should begin with 2.
OUTPUT:
b11029@linux-p6l1:~> sed 's/^/2/g' Seniors1029
22233| a.k.shukla | g.m | Sales |12/12/52|6000
29876|Jai Sharma| Director| Production|03/12/50|7000
25678|Sumit Chakraborty|d.g.m|Marketing|04/09/43|6000
22365|Barun Sengupta|Director|Personnel|05/11/47|7800
25423|n.k.sengupta|Chairman|Admin|08/30/56|5400
24356|Seema desai|Hr|Sales|12/12/83|4000