UNIX Assignments: Day 3
UNIX Assignments: Day 3
Objective: At the end of the assignment, participants will be able to understand and
implement:
• Sed
• Awk
Problems:
EmpData(Sample Database)
1. From the above database substitute the delimiter of first 3 lines with “ : “
2. From the above database substitute the delimiter with “ : ”
3. Insert the string “ PSL Employees” in the first line.
4. Store the lines pertaining to the directors, d.g.m and g.m into three separate files.
5. Using address store first 4 lines into a file Empupdate.
6. Find the pattern “account” in the database and replaces that with “accounts”.
7. Select those lines which do not have a pattern “g.m”.
8. Insert a blank line after every line in the database.
2. Write a script to get the report of the users logged on to the System in the following formats.
(Records should be sorted on logging time.)
Header must include company name and Date
Records in the format
Username Logged-in-time Terminal
Tailor should include total number of the users logged in.
3. Consider a text file containing the records (colon separated fields) in the format:
EmpName:EmpId:Subject:ObtMarks:TotMarks:Result
Write a script to get the result of “UNIX” Subject in the format (Considering the data file has
TotMarks=50 for UNIX)
EmpName:ObtMark:MarksOutof35
The header of the report must contain total marks and the tailor must specify the percentage
result for that subject.
Also generate another summary result containing total number of participants appeared, total
number of participants passed, and Name of the participants ranked Ist IInd, IIIrd with their
total score.
empno:name:job:deptno
deptno:deptname
empno:basic:hra:conveyance:medical:prof. tax: PF:TDS
Generate the pay slip as shown below by passing the empno as parameter to the awk script.
Empno 1001
Deptno 10
Job MGR
Curency INR
-----------------------------------------------------------------------------------------------
Earnings
-----------------------------------------------------------------------------------------------
BASIC 10,000.00
HRA 4,000.00
CONVEYANCE 9,600.00
MEDICAL 5,000.00
-----------------------------------------------------------------------------------------------
Total Earnings : 28,000.00
-----------------------------------------------------------------------------------------------
Deductions
-----------------------------------------------------------------------------------------------
PF 1200.00
PROF_TAX 200.00
TDS 1600.00
-----------------------------------------------------------------------------------------------
Net Pay : 25000.00
-----------------------------------------------------------------------------------------------
5. Generate the report as given below by passing the deptno to awk script
-----------------------------------------------------
Empno Name Job
-----------------------------------------------------
1001 Ketan MGR
1002 Sachin CLERK
----------------------------------------------------
6. Consider the Arizona roaster as an input data file for this exercise. Using any combination of
the text-processing utilities listed below, write a one-line shell command that performs each of
the following tasks
(a) reports the number of players on the roster