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

Unix Assignment

Uploaded by

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

Unix Assignment

Uploaded by

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

Unix Assignemnet

Assignment Details
2.Find the name of the directory you are currently placed. ------> pwd

3.Display the system date -------> date

4.Create three empty files in your home directory with the names file1, file2 and
file3. -----> cd ~ | touch file1.txt,file2.txt,file3.txt

5.Copy the file file1to the sub-directory HR under OFFICE directory. ------> cp
file.txt OFFICE/HR

6.Rename the file file1 to hrfile.txt ------> mv file1.txt hrfile.txt

7.Copy the file file2 and file3 to the sub-directory BILLS under the sub-directory
FINANCE under OFFICE directory.

||==-----> cp file2.txt file.txt OFFICE/FINANCE/BILLS

8.Rename file2 to billpaid.txt and file3 to billdue.txt. ------> mv file2


billpad.txt | mv file3 billdue.txt
9.Change the permissions of the ADMIN directory as below
Owner – All permissions
Group – Read and Execute permissions
Others – Read permission

||==-------> chmod 754 ADMIN

10.Copy the directory HR to another directory with name HR_new -------> cp -R HR


HR_new

11.Copy the file inside the directory HR to another directory with name TEMPDIR.
------> cp -R OFIICE/HR TEMPDIR

12.Delete the file inside the directory HR_New and then delete the directory HR_new
-------> rm -f HR_new/* | rmdir HR_new

13.Delete the directory TEMPDIR at one go. --------> rm -r TEMPDIR

14. List all the files in your home directory with all the attributes. --------> ls
-l

15.List all the text files in your home directory. ------> ls -l *.txt

16.List the users currently logged in. -----> who

17. Compare the file sample.txt inside the directory ADMIN with the file hrfile.txt
inside the directory HR. ------> cmp ADMIN/sample.txt OFFICE/HR/hrfile.txt

18.List the common lines between the two files mentioned in the previous question.
------> comm ADMIN/sample.txt OFFICE/HR/hrfile.txt

19. Display the lines which starts with the word “This” in the file sample.txt
inside the directory ADMIN. ------> grep "This" sample.txt

20. Display the count of lines having the word “sample” in the file sample.txt. The
search should be case-insensitive. ------> grep "sample" sample.txt | wc -l

21. Find all the empty files inside the directory OFFICE and delete them. ------>
22. Create a file called scores.txt in your home directory with the following
content

-------> cat>>scores.txt

Roll No|Name|Score
1|Raghu|80
2|Hari|50
3|Ram|80
4|Asha|40
5|Radha|60
Display the name of the top 3 scorers from the data stored in the file scores.txt.
-------> sort -t'|' -r -k3 scores.txt >> temp.txt | awk -F'|' '{if(NR!
=1&&NR<=4)print $2}' temp.txt

23. Using the file created in the above question, display the total scores of all
the students. Use awk command. -----> awk -F'|' '{if(NR>1)print $3}' scores.txt

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------

1.Write an awk script to print the numbers from 1 to 101. -------> awk
"{for(i=1;i<=101;i++) print i;}"

2. Create a file with name details.txt and store the following data in it. ------>
cat>>details.txt

First Name,Last Name, Contact


Atul,Sharma,9012334123
Rina,Barua,8012389167
Parna,Roy,9102367190
Robin,Dutta,8120490123
Payal,Sharma,7890123019

Write an awk script to display the details of the people from the file details.txt
in the following format :

Name :
Contact Number :

Note : The name field should be displayed as the first name and the last anme
together. ------> awk -F',' '{if(NR>1){print "Name :",$1," ",$2; print "Contact
Number :",$3}}' details.txt

3. Write an awk script to display the first name and the contact number of the
people whose last Name is "Sharma" from the file details.txt created in the
previous question.

--------> awk -F',' '{ if(NR>1){if($2=="Sharma") print "Name :",$1,"Contact


Number :",$3}}' details.txt

4. Write a shell script to take the name of the user as input and print a greeting
message to the user along with his/her name. The message is to be printed as "Good
Morning/Good Afternoon/Good Night" per the system time.

5. Consider the following file


EmpID;Emp Name; Designation;Salary
123;Sam;Trainee;20000
10989;Jack;Manager;60000
34567;Mary;Trainee;22000
35689;Alok;Trainee;25000
46576;John;Consultant;70000

Write a shell script to display the records of the employees with a given
designation. The designation will be given as command line argument.
6.Write a shell script to update the salary of all the employees of a particular
designation . The designation will be given as command line argument. Use the file
created in the previous question.

You might also like