Question

In: Computer Science

Linux Have your script request a word from the user, then checks if it is an...

Linux

Have your script request a word from the user, then checks if it is an ordinary file. If yes display the size of the file. If the name is a directory, then display the number of objects in that directory, then display the second line of a long listing of that directory.

Solutions

Expert Solution

#!/bin/bash

if [ $# -ne 1 ]
then
   echo "Enter filename as an argument"  
   exit 1
elif [ -f $1 ]
then
   echo "$1 is a ordinary file and size of $1 is `stat -c %s $1` Bytes"
  
else [ -d $1 ]      
   ls -l $1
fi


if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and i can edit and change the answers if you argue, thanks :)


Related Solutions

Linux Given a passed parameter to a script, request a number from the user and print...
Linux Given a passed parameter to a script, request a number from the user and print the parameter as many times as that number.
Write a PHP script that checks a word or a phrase (stored in a string variable)...
Write a PHP script that checks a word or a phrase (stored in a string variable) to determine if it is a standard palindrome, a perfect palindrome, or not a palindrome at all. Also, for each letter that the word/phrase contains, count and print the number of times that each consonant and vowel is encountered. Your output will look as follows: Word/phrase: racecar Perfect palindrome Contains consonants: r - 2 c - 2 Contains vowels: a - 2 e -...
In Kali Linux Write a script that ask the user to enter an IP address and...
In Kali Linux Write a script that ask the user to enter an IP address and a port number, then use the provided entries from the user to perform a query on your local network and determine if the given port is open on the provide network. Need to submit solutions for both below. 1.A short report showing the functionality of your code 2. your bash script
write a script in ruby to automate user account creation in Linux using a CSV file....
write a script in ruby to automate user account creation in Linux using a CSV file. Username is a combination of first initial last initial of the first name and last name in the last name followed by the first initial last initial(Ex. Sam Smith = smithsm). If two or more employees had the same first and last name appends a number to the end of the username. After accounts are created write the first and last names along with...
In PYTHON: Write a program that asks for a password from a user and checks if...
In PYTHON: Write a program that asks for a password from a user and checks if it satisfies the conditions: Contains at least one lowercase letter (a-z). Contains at least one uppercase letter (A-Z). Contains at least one digit (0-9). Minimum length 6 characters. Contains no spaces. If the password is valid, then the program prints “password accepted”. Otherwise, it keeps asking for more passwords from the user until a valid password is obtained. Hint: You might like to check...
This problem requires python(Project: Evaluate Word Problems) Write a script that enables the user to enter...
This problem requires python(Project: Evaluate Word Problems) Write a script that enables the user to enter mathematical word problems like "two times three" and " seven minus five", then use string processing to break apart the string into the numbers and the operation and return the result. So “two times three” would return 6 and “seven minus five would return 2. To keep things simple, assume the user enters only the words for the numbers 0 through 9 and only...
Linux Create a simple 'user' file -user name, user id, some few other fields (at your...
Linux Create a simple 'user' file -user name, user id, some few other fields (at your discretion). Name it 'users'. Enter about 10 entries there. Create a simple 'user_data' file -user name, phone, address etc at your discretion.. User names in both files should match. So there would be 10 users in both files. You probably want to do these files as tab -separated, rather than space separated.
Write a short bash script that takes in two arguments from a user, asks the user...
Write a short bash script that takes in two arguments from a user, asks the user whether they would like to add, subtract, multiply, or divide. Each of these operations must be a function that returns data.
LINUX In Linux command line write a shell script ex1.sh that uses IF THEN to Prompt...
LINUX In Linux command line write a shell script ex1.sh that uses IF THEN to Prompt the user to "Enter a number between 1 and 10". (Hint: Use the 'echo' and 'read' commands in the script. See the slide about the 'read' command) If the number is less than 5, print "The number is less than 5" (Hint: You will read input into a variable; e.g. read NUM. In the IF statement, enclose $NUM in quotes; e.g. "$NUM". Also, remember...
Linux project deployment Script Create a script “setup.sh” to automate the deployment of a flask application....
Linux project deployment Script Create a script “setup.sh” to automate the deployment of a flask application. The script must install all software dependencies such as: Python3 Pip3 Git Use github to clone this repository. Install the dependencies given in requirements.txt Start the server by executing the following command “gunicorn wsgi:app” requirements.txt Click==7.0 Flask==1.0.2 Flask-Cors==3.0.7 Flask-JWT==0.3.2 Flask-SQLAlchemy==2.3.2 gunicorn==19.9.0 itsdangerous==1.1.0 Jinja2>=2.10.1 MarkupSafe==1.1.1 PyJWT==1.4.2 six==1.12.0 SQLAlchemy==1.3.1 werkzeug>=0.15.3
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT