Essay File

668 Words Nov 26th, 2014 3 Pages
Discovery Exercises – Chapter 4

1. How can you create a file called history by using a redirection operator?
>history
2. Wait one minute or more and then change the timestamp on the history file you just created. touch history 3. Back up the history file to the file history.bak. history >history.bak

4. Sort the corp_phones1 file by the last four digits of the phone number. sort –n –k3 corp_phones1 5. Create and use a command that displays only the last names and telephone numbers (omitting the area code) of people in the corp_phones2 file. Place a space between the telephone number and the last name. cut –c 5-20 corp_phone1>corp_phones2

6. Assume you have a subdirectory named datafiles directly
…show more content…
mkdir mytest cp myfile ./mytest rm –r mytest

13. Use the cut command to create a file called descriptions that contains only the product descriptions from the products file you created earlier in this chapter. cut –d ‘,’ –f 3 products 14. You are worried about copying over an existing or newer file in another directory when you use the move command. What are your options in this situation? copy –u file1 ./

15. What command enables you to find all empty files in your source directory? find ./ –size 0

16. How can you find all files in your home directory that were modified in the last seven days? find ./ -mtime 7

17. How can you put the contents of each line of the product1 file side by side with the contents of the product2 file, but with only a dash in between instead of a tab? paste –d ‘-’ file1 file2 18. Make a copy of the corp_phones2 file and call it testcorp. Next create a single-line command that enables you to cut characters in the fifth column of the testcorp file and paste them back to the first column in the same file? (Hint: Two good solutions exist, one in which you use a semicolon and one with more finesse in which you use a pipe character.) corp_phones2>testcorp cut –d “ ” –f 5 testcorp >tempfile |paste tempfile testcorp

19. How can you use a command you have learned in this chapter to list the names of all users on your system? (Hint: Find out the name of

More about Essay File