Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 2 Create a directory (folder) in your users home called newsamples and move into the newly created directory. Task 3 Create a file in
Task 2 Create a directory (folder) in your users home called newsamples and move into the newly created directory. Task 3 Create a file in the newsamples directory called sample1 with the command, echo "Hello World." > sample1. Explain what this command is doing. Explain where the words "Hello World went to. Your answer below: Task 4 INFO 1111: Linux INFO-1111: LINUX Create a second file in the same directory called sample2 with the same words "Hello World". Provide a screenshot that this task was completed successfully. Your screenshot below: Task 4 Execute the following command to list files: ls samplel sample sample3 . This command should have output 2 lines. In your answer below, identify which line (actually put what the line is) be considered stdout and which line would be stderr. Explain why you received this output. Your answer below: Task 5 > Execute the following directory listing: 1s samplel sample sample3 fileA. Did any output appear on the screen when you ran this command? Explain why. Explain what happens when the > (greater than symbol) is used. What is the purpose of the fileA part of the command? Your answer below: Task 6 Open fileA and review the data in that file. INFO 1111: Linux 1 INFO-1111: LINUX 3 Task 7 Execute the following directory listing: ls samplel sample2 sample3 1> fileA. Open fileA and review the data in that file. What happened differently from task 5? Explain why. Explain how the 1> (number one and greater than symbol) is different from just the > (greater than symbol). Your answer below: Task 8 Execute the following directory listing: 1s samplel sample sample3 2> fileA. Open fileA and review the data in that file. What happened differently from task 5 and 7? Explain why. Explain how the 2> is different from 1> and >. Your answer below: Task 9 Task 5, 7 and 8 each demonstrated redirecting output to file. Was the data in fileA from Task 5 saved when you executed the command for task 7 or 8 or was the data overridden? Explain why. Your answer below: Task 10 Execute the following command: date >> fileA. Open and review fileA. Was the data overridden or added (appended) to the file? Your answer below: Task 11 "Clobbering" a file means overwriting its contents. To prevent unintentional clobbering, use the noclobber option to the set command. Type the following: set -0 noclobber INFO 1111: Linux INFO-1111: LINUX 4 Task 12 Now if you try override fileA with the command: echo "Greetings" > fileA . You get the error message: "bash: fileA: cannot overwrite existing file". Task 13 To remove the noclobber option: set to noclobber. Now attempt to override fileA like you did in task 12. It should now override the file without an error. Task 14 So far we have looked at redirecting stdout (stuff that happens on a computer screen) to someplace else such as a file. Let's now look at how to redirect stdin (stuff you type on a keyboard) to a program. In other words, instead of taking text we type and have a program do something with it, we will "funnel" text from a file (instead of the keyboard) to a program. Let's begin by using the tr (translate) command and interact with it using the keyboard. The tr command translates text from one format to another, for instance from lower case to upper case. Execute the following command, tr a-z A-Z. Then type "hello world" (all lower case) then press enter. The tr command should translate all lower case letters to upper case. jared@mormon [07:40:56 PM] [-] tr az A-Z hello world HELLO WORLD Type some more and press enter. Everything you type from the keyboard should change to uppercase letters. Press ctrl-c to cancel and return to the command line. Task 15 Instead of interacting with the tr command from the keyboard (stdin) we are going to have a text file interact with the tr command as if it was the keyboard. We are going to redirect stdin to the tr command. First let's be reminded what's in fileA. Execute the following command: cat fileA. Task 16 Now execute the command: tr a-z A-Z
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started