Set - 6

Question 1 :

Explain the following commands.

Answer :

$ ls > file1
$ banner hi-fi > message
$ cat par.3 par.4 par.5 >> report
$ cat file1>file1
$ date ; who
$ date ; who > logfile
$ (date ; who) > logfile


Question 2 :

What is the significance of the "tee" command?

Answer :

It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to the file specified by the user.


Question 3 :

What does the command " $who | sort –logfile > newfile" do?

Answer :

The input from a pipe can be combined with the input from a file . The trick is to use the special symbol "-" (a hyphen) for those commands that recognize the hyphen as std input.
In the above command the output from who becomes the std input to sort , meanwhile sort opens the file logfile, the contents of this file is sorted together with the output of who (rep by the hyphen) and the sorted output is redirected to the file newfile.


Question 4 :

What does the command "$ls | wc –l > file1" do?

Answer :

ls becomes the input to wc which counts the number of lines it receives as input and instead of displaying this count , the value is stored in file1.


Question 5 :

Which of the following commands is not a filter man , (b) cat , (c) pg , (d) head

Answer :

man A filter is a program which can receive a flow of data from std input, process (or filter) it and send the result to the std output.