Question
Using the Linux Terminal 1. Write a script to check command arguments (3 arguments maximum). Display the argument one by one. If there is no
Using the Linux Terminal
1. Write a script to check command arguments (3 arguments maximum). Display the argument one by one. If there is no argument provided, remind users about the mistake. If there an easy way to use a loop to get all arguments?
2. Write a script to display numbers from 1 to n, where n is an integer provided by users (if not, default to 10). Hint: use read command to accept user input.
3. . Write a script to display the following patterns on the screen. Number of rows and columns are taken from the command arguments; if they are missing, set default to 3 (rows) and 4 (columns). Hint: you will use a nested loop.
****
****
****
4. Create x empty files in a given directory (x is a number), following a naming format like this: myfile1, myfile2, etc. Ask the user to enter the first part file name and the number of files he/she wants to create. Hint: you may use the touch command to quickly create empty files. Take two screenshots:
a) Display the source code in an editor (Screenshot #4-1)
b) Execute your script in the terminal, and display the command and the result (Screenshot #4-2)
5. Write a script to create the following directory structure in a directory of users choice. The user can supply the directory of choice as an argument; if missing, prompt the user to enter one from the command line. Take two screenshots:
a) Display the source code in an editor (Screenshot #4-3)
b) Execute your script in the terminal, and display the command and the result (Screenshot #4-4)
6. Edit the script in the prior question.
a) Check if the user input (an existing directory) is valid; if not, ask the user to enter it again.
b) If the Data directory exists, then prompt for user actions: cancel or overwrite. Hint: use directory operators.
Command line script on one line: read -p "Enter a number: " max; sum=0; for ((i=1; i<=$max; i++)); do let sum+=i; done; echo "The sum from 1 to $max is $sum" Data Image Cache
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