6. Perform the following tasks. Effectively use channel rerouting, pipe operator
ID: 3879948 • Letter: 6
Question
6. Perform the following tasks. Effectively use channel rerouting, pipe operator and filter commands (see lecture notes #14-17)
a) Given any directory, find out all directories in it (including the hidden ones, or not).
b) Given any directory, find out the number of all files (including directories, and all hidden items) in it
c) Given any directory, find out the number of all hidden items (files and directories) in it
d) Take a screenshot (#3-3) of any one step a) to c) which clearly shows the command you use and the result.
e) Find out the first 20 commands executed and recorded in history.
f) Find all commands in command history that starting with “ls”, and save the result to a file. (This will be a bit challenging.)
7. Try the following and see what happens. Explains the behavior.
a) echo ".""."
b) echo "hello world"
c) echo hello world
d) echo "hello!1"; (how to display the text as is?)
8. Assume you have made the following variable assignment: person=zach How can you produce the following outputs on the screen?
a) zach
b) $person
b) "zach" - Take a screenshot (#3-4) which clearly shows the command you use and the result.
a) "$person"
9. Set var1 to the value as shown in the right figure. What’s the difference between the following two statements? How many arguments does each echo command see?
echo "$var1"
echo $var1
Explanation / Answer
6.)
a) ls -la | grep `^d'
b) find . -maxdepth 1 -type f
c) echo .*
d) take the screen shot of above command
e) history
above command gives the first 20 executed
f) history | grep "ls" >file
7.
a) echo ".""." will print two dots on screen like ..
b) echo "hello world" will print hello world on screen
c) echo hello world will also print hello world on screen
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.