222k views
0 votes
Write a bash script that accepts a person’s name as a command-line argument and simply prints out the following greeting: "Good day, ! Nice to meet you!", where is a positional parameter (i.e., a command-line argument) passed to the script. If the user does not enter a command-line argument when invoking this shell script, you will simply output: "Hope you have a great day!", without any name displayed. This bash script should be called rec03A.sh. SAMPLE OUTPUT (input in bold): $ ./rec03A.sh Mark Good day, Mark! Nice to meet you! $ ./rec03A.sh Hope you have a great day!

User Dvdwasibi
by
6.6k points

1 Answer

3 votes

Answer:

#!/bin/bash

if [ $# -gt 0 ]

then

echo "Good day, $1! Nice to meet you!"

else

echo "Hope you have a great day!"

fi

Step-by-step explanation:

User Henningst
by
5.8k points