15.2k views
3 votes
Write a single shell script hello.sh which can finish the list of tasks as below: 1. Greet user. E.g. Welcome to computer science society. 2. Contain a comment section with your name and email address. 3. Print a menu as below: Choose the item you want to buy? A. Apple Price: $1 per each B. Banana Price: $0.5 per each C. Orange Price $0.8 per each 4. Print the date(MM/DDAYYYy) after message "Purchase date:"5. Print out the current working directory. 6. List the total number of sh files in your home directory. 7. Print the values of variables HOME, PATH, USER and SHELL 8. List the PIDs of running processes associated to your account 9. Print if x > 2; y= x*2; else y =y/2; 10. Print "Good bye..." followed by the first argument from the command line.

1 Answer

3 votes

Answer:

Please note that the below script has been executed under bash shell in Ubuntu 16.04 system.

----------------------------------------------------------------------------------------------------------------------------------------

Script:

----------------------------------------------------------------------------------------------------------------------------------------

#!/bin.bash

#step 1

echo "Welcome to computer science society."

#step 3

echo "Date is = `date`"

#step 4

echo */ | wc

#step 5

echo $PATH

echo $USER

echo $SHELL

#step 6

echo "Printing disk usage"

echo "`df`"

#step 7

echo "Could you loan me "$"25.00?"

#step 8

echo "if x =2, x*x = 4, x/2 = 1"

#step 9

echo "`ls *.sh | grep c`"

#step 10

echo "Good Bye"

echo "Current Hour = `date +"%H"`"

#end of the script

Step-by-step explanation:

User MIantosca
by
5.7k points