0% found this document useful (0 votes)
159 views

Unix Assignment

The document contains assignments related to the UNIX operating system. It covers tasks like listing files and directories, manipulating files, modifying directory structures, sorting and filtering data. The assignments involve commands like ls, grep, sort to work with files, directories and extract information.

Uploaded by

Adharsh Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views

Unix Assignment

The document contains assignments related to the UNIX operating system. It covers tasks like listing files and directories, manipulating files, modifying directory structures, sorting and filtering data. The assignments involve commands like ls, grep, sort to work with files, directories and extract information.

Uploaded by

Adharsh Gowda
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

UNIX Assignments

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.)

SYSTEM (SUB DIRECTORY)

HARDWARE (SUB-SUB DIRECTORY) SOFTWARE

INPUT OUTPUT (SUB-SUB-SUB) APPL SYS

MOUSE PRINTER ( FILES ) WORDSTAR OS


SCANNER VDU (FILES ) LOTUS LINKERS

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.

6. Rename the file SCANNER to SCAN.

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 :

1. Count the total number of words in file text1.


2. Display the system date in following format:
Today is Friday, 17 May 96
3. Display the following text message on the monitor screen.

Deposited $100 to you account


4. Display the following message on the monitor.
The long listing of my home dir ………… is …………
(Hint: Use ls – l and pwd commands)

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:

a. List all the employees along with a row number


b. Sort the file as per the names
c. List top three salaried employees
d. Remove duplicate records from the file
e. List dept. no along with no. of employees working in each dept.
f. Sort the file in descending order of salary

7. EmpData(Sample Database file)

1122,j.b. saxena ,g.m. ,account ,12/12/52,6000


2233,n.k. gupta ,d.g.m ,sales ,31/12/40,9000
4545,anil agarwal ,director ,account ,06/07/47,7500
5656,lalit choudhury ,executive,marketing,07/09/50,5000
1265,chanchal singhvi,g.m. ,admin ,12/09/63,6000
0110,shyam saksena ,chairman ,marketing,12/12/43,8000
5566,jai sharma ,director ,account ,23/12/89,7000
7733,jayant ,d.g.m ,sales ,29/02/70,6000

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

----

You might also like