Вы находитесь на странице: 1из 3

ANAND INSTITUTE OF INFORMATION SCIENCE MCA IV SEMESTER 406- UNIX ASSIGNMENT DATE: 13-02-09 SUB-DATE: 20-02-09 1 Create the

e following directory structure in your home directory.

Change directory to hw1 (under the directory cs344) and execute the following commands and explain what action is performed when each of these commands are executed: 1. ls l /etc > file1 2. cat /etc/motd > file2 3. cat /etc/motd | wc l >> file2 4. cat file1 file2 > file3 5. cat < file3 Use the appropriate command to perform the following operations and for each item write down the command used: 1. display current time and date 2. determine other users logged into the machine 3. display the calendar for May, 2005 4. display current directory 5. copy file2 from the directory hw1 to the directory hw2 and rename the file as file1 6. copy file3 from the directory hw1 to the directory hw3 and rename the file as file1 7. display the top 15 lines of the file file1 in the directory hw3 8. copy all the files in the directory hw1 to the directory lab1 (under the directory cs304) 9. change directory to lab1 and list all the files in long format and sorted with the last file accessed being displayed last (latest file last) 10. change directory to hw4 and copy the file file1 from directory

hw1 to the directory hw4 11. list all the files, directories, and subdirectories starting from your home directory 12. create a new directory called tmp in your home directory. 13. list all the files, directories, and subdirectories starting from your home directory and send the output to a file called myfiles in the directory tmp 14. determine the number of lines in the file myfiles 15. remove the directory tmp including all files in that directory using a single command 4 For the following commands explain what action is performed and write down the output produced: cp ~puri/yppasswd ~/spring2005/cs344/hw2/ b. cd ~/spring2005/cs344/hw2; cut -d':' -f5 yppasswd | cut -d',' -f1 | sort +1 | tee users c. grep n i v cs330 yppasswd d. tr ':' '\t' < yppasswd List your home directory to the file dirlist. 1. Make the directory adir 2. List the files in the current directory to verify that the directory adir has been made correctly. 3. Change directories to adir. 4. Verify that you have succeeded in moving to the adir directory. 5. Create the file testfile and put your name and address in it. 6. Verify that the file testfile exists. 7. List the contents of the file testfile to the screen. 8. Make a copy of the file testfile under the name secondfile. 9. Verify that the files testfile and secondfile both exist. 10. List the contents of both testfile and secondfile to the monitor screen. 11. Delete the file testfile. 12. Verify that testfile has been deleted. 13. Clear the window. 14. Rename secondfile to thefile. 15. Issue the command to find out how large thefile is. How big is it? 16. Copy thefile to your home directory. 17. Remove thefile from the current directory. 18. Verify that thefile has been removed. 19. Copy thefile from your home directory to the current directory. 20. Verify that thefile has been copied from your home directory to the current directory. 21. Change directories to your home directory. 22. Verify that you are in your home directory. 23. Verify that a copy of thefile is in your home directory. 24. Remove thefile from your home directory.

5 6

25. Remove thefile from the directory adir. 26. Remove the directory adir from your home directory. 1. Type one page of text and try the following commands check the result. For example the file name is labTextFile grep -n "out" labTextFile 1. grep -n "out" labTextFile 2. grep -n "for$" labTextFile 3. grep -n "^The" labTextFile 4. grep -n "^The.*for$" labTextFile 5. grep -n "[0-9][0-9][0-9]" labTextFile 6. egrep -n "the|for" labTextFile 7. egrep -n "hi+" labTextFile 8. egrep -n "fun$|fun[^n]|funn[^y]" labTextFile 9. egrep -n "(^| )[a-zA-Z][a-zA-Z] [a-zA-Z][a-zA-Z]( |$)" labTextFile 10. egrep -n "^[A-Z].*line|to.*d$" labTextFile

Вам также может понравиться