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 ?    22 Yes 7 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 4 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 7 No



Post New Answer



More Shell Script Interview Questions

How to replace following lines, catch (DAOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } catch (BOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw e; } catch (Exception e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } Needs to be changed in to, catch (DAOException e) { AppException.handleException (null, null, e, null, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); } catch (BOException e) { AppException.handleException (null, null, null, e, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 0); } catch (Exception e) { AppException.handleException (null, null, null, null, null, e, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); }

0 Answers   Wipro,


how do you write sql queries using shell script for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO columns in EMP table how you display EMPNO,SAL FIELDS from emp in SHELL SCRIPT please explain with an example

4 Answers  


If you have a string "one two three", which shell command would you use to extract the strings?

5 Answers  


what is the meaning of First line of shell script ,what is meaning of #! pleas explain brifly

4 Answers  


Create a bash shell script to sort and then uniq the file from the command line & store it to a new file and output the results to the screen. Name this script "sortAndUniq.sh"

4 Answers  






write a program to display all the files from the current directory which are created in particular month

6 Answers  


What is the need of including script interpreter in your shell script?

2 Answers  


what is "umask"?

6 Answers   Wipro,


What is the difference between a 'thread' and a 'process'?

3 Answers  


what does "kill -9" and "kill -1" do

2 Answers   Amazon,


how did u debugging in unix/ linux platform ??( project Related)

2 Answers   Symphony,


How u convert string "hi pravin how are you?" to "Hi Pravin How Are You?"

12 Answers   Cap Gemini,






Categories