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

What is basename in shell script?

0 Answers  


What is shell chemistry?

0 Answers  


What is difference between shell and bash scripting?

0 Answers  


How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?

0 Answers  


Script S1 (which copies .dat files from one directory1 to another directory2) run continuously. Write Script S2 which kills S1 first, compresses all .dat files in directory1 and directory2 successfully, re-run Script S1 and stops self i.e. S2.

2 Answers   IBM, TCS,






What is a batch file used for?

0 Answers  


How to rename all the files in a folder having specific extension? Example: I have some files with extension (.txt) in a folder name 'Test'. I have to rename all the .txt files in a test and its subdirectories to .my extension.

15 Answers   Interra IT,


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

0 Answers  


What is a shell environment?

0 Answers  


How do I open the shell prompt?

0 Answers  


Explain about sourcing commands?

0 Answers  


What are the different types of commonly used shells on a typical linux system?

0 Answers  


Categories