Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Perform the following tasks. Effectively use channel rerouting, pipe operator an

ID: 3744625 • Letter: P

Question

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 "Is", and save the result to a file. (This will be a bit challenging.)

Explanation / Answer

a)

ls command is used to list all the files and directories in the given location. –R is given to get the list recursively. Note: Replace the directoryName with the directory of your system.

ls –R directoryName

b)

output of ls command is pipelined with wc to count the directories within the given directory.

ls directoryName | wc –l

c)

Same as above only –a is used in ls command to give the list of hidden files.

ls directoryName -a | wc –l

e) history command will list first 20 commands executed.

history -20