We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Assignment - ll
Name : Kevadiya parth Babubhai Roll No : 9
Division : B Semester : 5 Subject : Unix
1. Change the delimeter of file stud.lst from | to ; .
Ans :- cat stud.lst|tr “|” “;” 2. Count the occurrence of each word. Ans :- cat stud.lst|tr “|” “\n”|sort|uniq -c
3. Display last accessed file.
Ans :- ls -lut|head -n 2|tail -n 1 4. Display last three modified files. Ans :- ls -lut|head -n 4|tail -n 3
5. Display smallest file of file X1.
Ans :- ls -lSr|head -n 2|tail -n 1
6. Count total number of alphabets in a file F1. Ans :- cat f1|tr -cd “[A-Z][a-z]”|wc -c 7. Write a command to remove the repeated lines from the file F1. Ans :- sort f1|uniq 8. Display file size and file name of all files in current directory. Ans :- ls -l|cut -d “ ” -f 5,9 9. Display all available users and their home directory. Ans :- cat /etc/passwd |cut -d “:” -f 1,6 10. Count number of vowels in a file X1. Ans :- tr -cd “[a,e,i,o,u]” <x1|wc -c 11. Display last word of the file X1. Ans :- tr “” “\n” <x1|tail -n 1 12. Count the length of last but one line of x1.
Ans :- cat x1|tail -n 2|head -n 1|wc -c
13 Count the number of words in line 4 to 6 of file f1. Ans :- head -n 6 stud.lst|tail -n 3|wc -w 14. Delete all special characters from the file f1. Ans :- tr -cd “[0-9][a-z][A-Z]” <f1 15. Count total number of spaces in a file F1. Ans :- tr -cd “ “ <f1|wc -c 16. Display 5 largest file details of current directory.* Ans :- ls -lS|head -6|tail -5 17. Display line number before each line. Ans :- cat -n stud.lst 18. Display all uniq word of file F1. Ans :- sort f1|uniq -d 19. List out all files of current directory(do not use ls). Ans :- dir 20. Set the permissions of f1 file to "owner can read and write; group can read only; others can read only". Ans :- chmod u=rw,g=r,o=r f1