Question

Revision Question 3 on Linux. Please explain the shell script commands in the context of post...

Revision Question 3 on Linux. Please explain the shell script commands in the context of post execution.

You have just logged in and have a directory called "novel" in your home directory containing the following files:

chapter1.docx chapter2.docx chapter3.docx draft.pdf save

where "save" is itself a directory and contains the files

Attributes.txt draft.pdf.1 draft.pdf.2 draft.pdf.3 indexA.txt indexB.txt list1.txt list2.txt

a) Describe the results you would expect when executing the following shell commands:

i) ls novel/save/*A*

ii) ls novel/*r[23]*

iii) rmdir novel

iv) ls novel | wc -l

v) rm -r novel/save

(assume each command is run when the directory "novel" is as described above)

b) Consider the following short shell script

#!/bin/sh

cd $1

cnt = ` ls save/$2* | wc -l`

for i in $2*

do

cnt=$((cnt+1))

cp $i save/$i$cnt

done

If this script is stored in a file called arch, what would be the effect of running this shell command:

./arch novel draft

c) Describe the underlying design principle behind the Linux command set - often called the "UNIX philosophy".

  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) i) list all files that contain A So it will print 3 indexA.txt

2) list all files that contain r in dir Novel

3) The rmdir command removes novel directory

4) Number of lines without filename in Novel - it should give 6

5)rm -r novel/save would delete the directory named “save” and all files in it.

Add a comment
Know the answer?
Add Answer to:
Revision Question 3 on Linux. Please explain the shell script commands in the context of post...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a shell script called GetMyStuff.sh that will provide the above information (the script must be...

    Write a shell script called GetMyStuff.sh that will provide the above information (the script must be a executable, and must work regardless of which directory it is in). Also, just saying cat MyStuff.txt is not sufficient. (1.0%) A pipeline is the combination of at least 2 commands, where the output of command1 is the input for command2. The syntax is command1 | command2 where | is the pipeline operator. Read the man pages about the ls and wc commands. Devise...

  • You are currently running/debugging a shell script program in the foreground that seems to be in an infinite loop, to terminate/kill the shell script program. 7. (type/enter - control C to send a &#3...

    You are currently running/debugging a shell script program in the foreground that seems to be in an infinite loop, to terminate/kill the shell script program. 7. (type/enter - control C to send a "program interrupt" ) or (contact the sysadmin person to kill your shell script program) 8. The UNIX/Linux exit command entered on the KORN shell command line will exit the shell session properly (best practice). [True / False] When killing a background process with the kill command you...

  • Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell...

    Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell variables, and .profile script file, echo SHELL, HOME, PATH, MAIL and TERM are predefined shell variables. You can use the value of a shell variable in a shell command putting $ in front of it. For example, to display the value of the HOME directory of the user, specify $HOME in the echo command like echo $HOME. Do not give just the value of...

  • Write a script using simple shell commands. The script takes a command line argument that specifies...

    Write a script using simple shell commands. The script takes a command line argument that specifies a directory dir. The script first changes directory to dir, then prints the following in sequence: (a) A line starting “Current date and time: ”. Then on the same line, the current time and date. (b) A line starting “Current directory is : ”. Then, on the same line, the absolute pathname of the current working directory. (c) An empty line (d) The line...

  • Explain what the following UNIX command does: Is 'echo I.txt' Please type shell commands (for Windows....

    Explain what the following UNIX command does: Is 'echo I.txt' Please type shell commands (for Windows. UNIX, or any other system that you like) for: creating a directory called hello world list the contents of this directory create a file called iwashere.txt display the contents of the file iwashere.txt from the command-line Please write a simple program in C for accepting a string from the command-line, reversing and printing the reversed string to standard output.

  • COSC 3411 /ITAP 3411 Homework (UNIX Shell Commands) How would you ensure that all ordinary files...

    COSC 3411 /ITAP 3411 Homework (UNIX Shell Commands) How would you ensure that all ordinary files created by you have rw-rw---- as default permissions? How would you sort in the background a file called "bad.txt", and place the results in a file called "sort.txt"? Archive the contents of your home directory (including any subdirectories) using tar. Compress the tar archive with gzip. Now extract their contents. Use the “find” command to locate in /docs and /usr/docs all files that Begin...

  • Please answer the following questions because I am not understanding it Description Investigate UNIX/Linux Files Systems...

    Please answer the following questions because I am not understanding it Description Investigate UNIX/Linux Files Systems by answering the questions below Requirements  Save the recorded information in an ASCII file named “prog2.txt”. The file, “prog2.txt”, must be located in the directory: $HOME/itec400/homework  Make sure the permissions on “prog2.txt” are set to 705.  Solutions to problems below may require research on the web  Record the questions below and the answers in “prog2.txt”. 1. What is the purpose...

  • Please help with this linux lab. Please include screenshots as I keep getting errors when I...

    Please help with this linux lab. Please include screenshots as I keep getting errors when I attempt this lab. Thank you in advance Example 1 Enter the system root directory cd / pwd [this command prints working directory] Here is how to go back to your home directory: cd ~ pwd Example 2 Use the Change directory command cd /labs/lab1/ohio inside the ohio folder use the Touch command to create a file called ohiostate.txt /labs/lab1/ohio/touch ohiostate.txt Use the pwd and...

  • Unix/Linux The purpose of this lab is to practice the commands to manage and organize files...

    Unix/Linux The purpose of this lab is to practice the commands to manage and organize files and directories: How would one go about this? Thanks. Task 1: Preliminaries: 1) If you have not already done so, create a directory called bin under your HOME directory. 2) If you have not already made a copy (using ftp) of the file called famous.dat from the Assignment#1, do that now. 3) Make bin the active/working directory. Task 2: Perform all of the following...

  • Question 11 1 point possible (graded) The commands in the pipeline $ cat result.txt | grep...

    Question 11 1 point possible (graded) The commands in the pipeline $ cat result.txt | grep "Harvard edX" | tee file2.txt | wc -l perform which of the following actions? From result.txt, select lines containing “Harvard edX”, store them into file2.txt, and print all unique lines from result.txt. From result.txt, select lines containing “Harvard edX”, and store them into file2.txt. From result.txt, select lines containing “Harvard edX”, store them into file2.txt, and print the total number of lines which were...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT