write a non recursive shell script that accepts any number
of arguments and prints them in the reverse order

Answers were Sorted based on User's Feedback



write a non recursive shell script that accepts any number of arguments and prints them in the rev..

Answer / naresh babu

echo "no of arguments:$#"
echo "arguments in reverse order:"
for i in $*
do
j=$i" "$j
done
echo $j

Is This Answer Correct ?    26 Yes 9 No

write a non recursive shell script that accepts any number of arguments and prints them in the rev..

Answer / drths

$ sh rev.sh 123 ---Script name with 1 cmd line argument
------------------------------
#! /bin/sh
abc=$1 ###123 will store in abc
pqr=`echo $pqr | rev` ### 123|rev
echo $abc
-----------------------------
o/p : 321

Is This Answer Correct ?    0 Yes 5 No

write a non recursive shell script that accepts any number of arguments and prints them in the rev..

Answer / amar

./reverse frg gh rtyh
no of arguments:3
arguments in reverse order:
rtyh gh frg

Is This Answer Correct ?    0 Yes 8 No

Post New Answer

More Shell Script Interview Questions

How would you print just the 25th line in a file using smallest shell script?

4 Answers  


How to get the first line from a file using just the terminal?

0 Answers  


What is bash eval?

0 Answers  


Hi, all Scripting professional. Q. I have written script1.sh and calling script2.sh in script1.sh file using bash shell as interpreter and my log in shell also bash shell.My code like Script1 #!/bin/bash echo "My script2 call" . script2.sh Here script2.sh file run successfully but when I have changed my interpreter bash to ksh like #!/bin/ksh Error are comming script2.sh command not found. Guid me how to call other script in our main script.

2 Answers  


What are types of shells?

0 Answers  






How do I open the shell in cmd?

0 Answers  


Hi Friends, I am currently Undergoing Course On Testing.I am Planning To Keep Fake Resume.Can any One tell me the ways to Prepare i.e, Real Time experience For Manual Testing. With Regards, Vikram

1 Answers  


What is bash coding?

0 Answers  


How can you find out how long the system has been running?

0 Answers  


How can I set the default rwx permission to all users on every file which is created in the current shell?

0 Answers  


How important is shell scripting?

0 Answers  


What lives in a shell?

0 Answers  


Categories