Create a bash shell script that reads a line from the user
consisting of 5 words and then prints them out in reverse
order. Name this script "reverse.sh"

Answer Posted / priyanka joshi

read line;
echo $line | awk '{ for ( i = NF; i > 0; i--) print $i}' |
tr "\n" " "

Is This Answer Correct ?    5 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the crontab?

543


Explain about non-login shell files?

696


Write a shell script that adds two numbers if provided as the command line argument and if the two numbers are not entered throws an error message.

801


determine the output of the following command: echo ${new:-variable}

546


What is a shell environment?

577






What is bash command used for?

583


How to print all array elements and their respective indexes?

510


Explain about gui scripting?

626


How do I run a .sh file on mac?

679


How do I run a script from command prompt?

562


What is echo $shell?

625


How will you find the 99th line of a file using only tail and head command?

1997


Is powershell a language?

561


How will you connect to a database server from linux?

557


How do I run a powershell script?

576