In: Computer Science
Unix / Linux
21.
Given the following command pipeline, provide a diagram (ascii art) or detailed description indicating all the Input/Output (I/O) connections. Every stdin, stdout, and stderr for each command will need to connect to something.
grep a < words | wc -l > a_count.txt
22.
Explain what is wrong (if anything) with the following command pipeline.
cd | ls
23.
Stream Editor:
Write a sed command to delete digits, but only on lines that end with a period. Assume a file named exam.txt is used for input and changes will be displayed to the screen and not saved to the file.
24.
ls command
What option is used to format the output in a single column?
25.
ls command:
List two different options that will indicate "file type" in the output. Explain.
21) grep a < words | wc -l > a_count.txt
this command is used to find certain things on file or text. but here angular brackets are used, so the expression evaluated first. there can be two cases... as mentioned here
a) no words file, then it will generate error and display it on the screen that words no such file.
b) there is words file, then the total line will be counted in that file, and then at the end command will generate error. saying that no such token found.
22) cd|ls
since there is not error in the given pipe line, this will simply foward the return code of cd command to the command ls. and this command will only gives the output of ls command which is nothing but the content of the current directory.
23) sed -e '/^[0-9].*$/d' exam.txt
This command will perform said task.
24) ls -1
ls --format=single-column
this command will give output in single column.
25) first option with ls command is "-l"
it will show output along with type of file like as mentioned below:
second option is "-F" it will append * to the file and / to the directory.
So, -l and -F are two ways.
Hope this helps.