Unix Assignment
Unix Assignment
Assignment Details
2.Find the name of the directory you are currently placed. ------> pwd
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
7.Copy the file file2 and file3 to the sub-directory BILLS under the sub-directory
FINANCE under OFFICE directory.
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
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
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
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.
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.
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.