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
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 |
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 |
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 |
What is basename in shell script?
What is shell chemistry?
What is difference between shell and bash scripting?
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?
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.
What is a batch file used for?
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.
How can you find out how long the system has been running?
What is a shell environment?
How do I open the shell prompt?
Explain about sourcing commands?
What are the different types of commonly used shells on a typical linux system?