Q1 60-80 Flashcards
When will ‘wc < chap0[1-5]’ work?
When there is a file called “chap0[1-5]” in the same directory.
wc (Word Count) will display the lines, words and characters of a file.
Is ‘>foo < bar sort’ a legitimate Unix command, and what does it appear to do?
No it is not. >foo is an Invalid Null Command.
But it appears to write Null to ‘foo’, then send the contents of ‘bar’ to ‘foo’ and sorting it.
What happens when you execute (i) cat > foo if foo contains data, (ii) who»_space; foo if foo doesn’t exist?
Executing cat > foo will overwrite foo, and who»_space; foo will create foo if it does not exist.
If foo does exist»_space; will append the data to the end of foo.
When executing the following two Unix commands: sort filename and sort
The different errors come from who is opening the file. sort or the shell (in the case of
How do the commands wc foo and wc < foo differ?
In ‘wc foo’ foo is opened by wc.
In ‘wc < foo’ foo is opened by the shell and redirected to wc.
You want to concatenate two files, foo1 and foo2, but also insert some text after foo1 (but before foo2) from the terminal. How will you do this?
UNKNOWN
How do you redirect each of the standard output and standard error to two different files in the Bourne-shell and C- shell? Give an example.
Bourne-shell: cat foo bar 2> error_file
C-shell: (cat foo bar > output_file) >& error_file
How do you redirect each of the standard output and standard error to the same file in the Bourne-shell and C-shell? Give an example.
Bourne-shell: cat foo bar > output_and_error_file 2>&1
C-shell: cat foo bar >& output_and_error_file
How do you redirect the standard input from a file in the Bourne-shell and C-shell? Give an example.
The redirect input symbol, <, instructs the shell to redirect a command’s input from the specified file instead of from the keyboard.
What will you get if you execute ls 1> out.file in Bourne-shell and in C-shell? Explain.
Bourne-shell: You will overwrite out.file with the output of ‘ls’. (as bourne-shell treats 1> as >)
tcsh: 1 not found, create empty out.file
Display lines 30 through 40 of the file poem on your screen. Assume that the file poem has more than 40 lines.
head -30 poem
Print the 5th line in a file called input_file.
head -5 input_file | tail -1
How do you select from a file: (i) lines 5 to 10, (ii) second-to-last line?
NOT SURE
tail -2 letter.txt | head -1
How does head display its output when used with multiple filenames?
In order of the provided file names, using ==> foo <== as titles.
What is the file /dev/null used for?
A virtual file that is always empty and used to dispose of unwanted data. Basically a black hole.