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

1. Use the “man” command to view documentation of the “more” command. Find out w

ID: 3878348 • Letter: 1

Question

1. Use the “man” command to view documentation of the “more” command. Find out what the option “-d” does. Use this option

with the “more” command to view the “rgb.txt” file.

2. Use the “type” command to find out if the following commands are shell builtins: type, less, export, ls, bash, man.

4. On the command line, type “cat > lab3-4” and return to quickly create a new text file. Enter your name and major as the file

content. Use Ctrl+d to end editing. Then use the “cat” command again to append some of your skills to (note NOT to replace)

the “lab3-4” file. Check your file to make sure you do not overwrite the original content

5. When you use the redirect output symbol (>) with a command, the shell creates the output file even the command fails.

Demonstrate that. Hint: how to generate a failed command (i.e. a command that produces an error message)?

6. Perform the following tasks. Effectively use channel rerouting, pipe operator and filter commands

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

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

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

Taking the first four questions in the list:-

1) man more

-d more will prompt the user with the message "[Press space to con
tinue, 'q' to quit.]" and will display "[Press 'h' for instruc
tions.]" instead of ringing the bell when an illegal key is
pressed.

more -d rgb.txt

2) type is shell builtin

less is not shell builtin

export is shell builtin

ls is not shelll builtin

bash is not shelll builtin

man is not shelll builtin

4) cat >>lab3-4.txt

Enter the text to be appended. Then press ctrl+D.

5) cat fail.txt>output.txt

Here the command will fail if there is not fail.txt in the current directory but the output.txt file will still be created.