File Manipulation
- What does this sequence of commands do? Do the two mv commands
cancel each other?
$ date >datefile
$ mkdir pluto
$ mv datefile pluto
$ mv pluto datefile
Why do I get an error message here?
$ date >newdatefile
$ cat newDatefile
cat: cannot open newDatefile
Show a Unix command pipeline that will count how many Unix manual pages have the word
"file" in their descriptions. (Hint: Using the correct option to the man
command will get you half-way there.)
An option to the cat command will number the output lines. Show a
Unix pipeline that will display the line number and lines from your .profile
file that contain the word if . (The output should include the line
number of the line containing the if as well as the line itself.)
The sort command, like many Unix commands, will read from standard
input if you don't give it a file name to sort. Explain why the output of the
following sort puts 2 after 10.
Which option to the sort command will sort the numbers correctly?
$ sort
1
2
10
20
^D (this ^D means you type control-D, signalling End-Of-File [EOF])
Output:
1
10
2
20
In class we developed a Unix pipeline that created class EMail addresses followed by
names by using ypcat and the awk program. Modify
the pipeline so that the name comes first, followed by the EMail address. Show the
new pipeline and the first few lines of the output.
How many lines contain the word font in the html
source for the Problem Set 4 web page? Explain how you found this out.
What Unix command will tell you if two files have the same content? Give
an example of its use.
What Unix command will tell you if two files are really the same file (the two
names actually point to the same data)? Give an example of its use.
Give a Unix pipeline that will show the five most recently modified files in the current
directory.
Give a Unix pipeline that will show the five least recently accessed files in the
current directory.
Answer this question using vi on a Solaris computer. Create a
file with the word "Here" in it in your home directory.
Start up vi, editing this file you just created. Change
"Here" to "There" but don't save the file yet. Use the cd
command inside vi to cause vi to change to the /tmp
directory. Now exit vi and save the buffer using ZZ
. In which directory did vi save the file? Use the ls
command and the cat command to show the date and contents of each
file. (Use cut and paste from you terminal window to demonstrate what happened.)
Answer question 12, this time using vi (or vim) on a
Linux computer.
|