
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
![5) Example: Write a bash script that asks the user to enter two arguments. The script creates a
directory with the name specified in the second argument. It then creates a simple file with the name
specified in the first argument under the created directory. The interface should be as follows:
Enter filename: file1
Enter directory name: dir1
Creating directory dir1
Creating file file1
Moving file file1 to directory dir1
#!/bin/bash
read -p "Enter filename:" f
read -p_"Enter directory name:" d
a[0] = $f
a[1] = $d
echo
echo "Creating directory ${a[1]}"
mkdir ${a[1]}
echo "Creating file ${a[0]}"
echo "This is a simple file" > ${a[0]}
echo "moving file ${a[0]} to directory ${a[1]}""
mv ${a[0]} ./${a[1]}/${a[0]}](https://content.bartleby.com/qna-images/question/3db2b482-f243-4eff-8c03-4481cb283fba/08f80725-fea1-4bd9-9f8b-bb533586aa86/gkq46a6_thumbnail.png)
Transcribed Image Text:5) Example: Write a bash script that asks the user to enter two arguments. The script creates a
directory with the name specified in the second argument. It then creates a simple file with the name
specified in the first argument under the created directory. The interface should be as follows:
Enter filename: file1
Enter directory name: dir1
Creating directory dir1
Creating file file1
Moving file file1 to directory dir1
#!/bin/bash
read -p "Enter filename:" f
read -p_"Enter directory name:" d
a[0] = $f
a[1] = $d
echo
echo "Creating directory ${a[1]}"
mkdir ${a[1]}
echo "Creating file ${a[0]}"
echo "This is a simple file" > ${a[0]}
echo "moving file ${a[0]} to directory ${a[1]}""
mv ${a[0]} ./${a[1]}/${a[0]}
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

Knowledge Booster
Similar questions
- object of type streambuf. This object may represent a memory block that acts as an intermediary When we operate with file streams, these are associated to an internal between the stream and the physical file. For example, with an ofstream, each time the member function put (which writes a single character) is called, the character may be inserted in this intermediate buffer instead of being written directly to the physical file with which the stream is associated. O batch O switch binary O bufferarrow_forwardCould you verify or provide the more accurate answer?arrow_forwardBash Shell Script Programming Assignment **Make sure to name the script file as it mentions** Question 1. Create a shell script file called q1.sh Write a script that would accept the two strings from the console and would display a message stating whether the accepted strings are equal to each other. Question 2. Create a shell script file called q2.sh Write a bash script that takes a list of files in the current directory and copies them as into a sub-directory named mycopies. Question 3. Create a shell script file called q3.sh Write a Bash script that takes the side of a cube as a command line argument and displays the volume of the cube. Question 4. Create a shell script file called q4.sh Write a Bash script that prompts you for a user name and displays the corresponding user’s id number (UID), group id number (GID), and his/her home directory. Note: this information can be found in the /etc/passwd file. Question 5. Create a shell script file called q4.sh Write a bash…arrow_forward
- Please Help ASAP!!!arrow_forwardProblem 1: Write a Bash script that takes the name of a file or directory as an argument, 1. reports if it is a directory or a file, and if the user has read, write and execute permission on the file or directory, and 2. if it is a file, reports the size of the file and the category of the file based on its size. If the file size is greater than 1MB (1048576B), the file is a large file; if the file size is less than or equal to 1MB (1048576B) and the file size is greater than 100KB (10240OB), the file is a medium file; otherwise, it is a small file. Use a sequence of if statements on the file name or file size to determine the information. To get the file size, use command du -b and command cut. Read their manual for how to use them.arrow_forwardC programmnigarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY