Unix Assignment
Unix Assignment
Section 1:
1. List all the files and sub directories of the directory /bin.
2. List all the files including hidden files in your current directory.
3. List all the files starting with letter ‘r’ in your current directory.
4. List all the files having three characters in their names, from your current directory.
5. List all the files with extension .doc in your current directory.
6. List all the files having the first letter of their name within the range ‘l’ to‘s’, from
your current directory.
7. Create a file text1 and read its input from keyboard.
8. Copy the contents of file text1 to another file text2.
9. Append the contents of file text2 to file text1.
10. Display the output of command ls –l to a file and on the output screen.
11. Delete all the files with their names starting with “tmp”.
List only the directories in your current directory
Section 2:
1. Display your current working directory.
2. Create following directory structure under your Home directory
(Note: Your home directory is where you login to.)
3. List detailed information about all the files and directories of Hardware directory while
your current directory is still the home directory.
4. Change your current directory to SYS and list the names of all files and subdirectories in
the directory sub tree starting that starts from your home directory.
5. Copy the file SCANNER to directory SYSTEM while your current directory is APPL.
7. Read some text form Keyboard and append it to the file SCAN.
8. Remove the directory sub tree starting from SYSTEM in one go.
(Note: This command is potentially dangerous)
Section 3 :
5. Display the name and count of the directories in the current directory.
6. Create the file employee.txt having colon (: ) separated fields.
The fields of the record are: enumber, ename, eposition, esal, edoj, edept.
And now answer the following:
Solve the below assignment using either grep, egrep and fgrep
a) From the above database substitute the delimiter of first 3 lines with “ : “
b) From the above database substitute the delimiter with “ : ”
c) Store the lines pertaining to the directors, d.g.m and g.m into three separate files.
d) Using address store first 4 lines into a file Empupdate.
e) Find the pattern “account” in the database.
f) Select those lines which do not have a pattern “g.m”.
8. Consider the Arizona roaster as an input data file for this exercise. Using grep , sort, wc ,
head, tail, pipe do the following activities :-
a) display the number of players on the roster
b) displays the roster in order by jersey number
c) displays the roster in alphabetical order by surname
d) displays the heaviest five players
e) displays all players who attended Wisconsin
The Roaster is given below (separating by comma) :-
JersyNo, Name,surname ,linebackers,Weight , Date , Experience, Country
20 , Anderson, Damien ,RB 5'10" , 212 , 07/17/1979 , 3 ,Northwestern
30 , Ayanbadejo, Oba ,FB 6'02" , 235 , 03/05/1975 , 5 ,San Diego
92 , Berry,Bert ,DE6'03" , 250, 08/15/1975 , 7 ,NotreDame
81 , Boldin,Anquan ,WR6'01" ,215 , 10/03/1980 ,2 , FloridaState
91 , Bryant,Wendell ,DT6'04" ,303, 09/12/1980 , 3 , Wisconsin
35 , Carter,Dyshod ,DB5'10" ,197 , 06/18/1978 ,2 , Kansas State
52 , Fisher,Levar ,OLB6'01" ,235 , 07/02/1979 ,3, NorthCarolina
11 , Fitzgerald,Larry ,WR6'04" ,229, 08/31/1983 ,10 ,Pittsburgh
63 ,Garcia,Frank ,G6'02" , 302, 01/28/1972,10, Wisconsin
64 ,Grace,Steven ,C6'03" ,295, 02/13/1979 , 3,Arizona
84 ,Hamilton,Lawrence ,WR6'03" ,205 ,08/31/1980 ,2,StephenF.Austin
----