bash scripting homework question
Write a shell script to reverse the set of numbers given in command line except the last argument.
Display the last argument as it is in the end. See the output to get more details. The script can take any number of arguments as input. $ ./revbutlast.sh 1 2 3 4 5 The output is 4 3 2 1 5 $ ./revbutlast.sh 4 3 2 1 The output is 2 3 4 1 $ ./revbutlast.sh ./revbutlast.sh expects arguments $ ./revbutlast.sh 1 The output is 1 --- Without using any loop like while, for write the script and name it as revbutlast_withoutloop.sh |
haha, nice.
this is not urgent for us at all. you've not said please or thank you you've not even tried to hide that it's homework, and copied it verbatim. Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member. |
I recommend you start doing the homework. A better (answerable) question will occur to you once you do.
|
thank you guys..its ok its apppearing on google..
can anyone tell how is it done using Bash scripting |
it's appearing on google??? huh??
No, we can't. Go learn something for yourself. |
i mean its ok if the question appears on google...actually i wasted 4 hrs on it and developed a headache...pls help
|
So what do you have so far, and what is it doing/not doing?
|
Quote:
Since you're too lazy to even TRY to do your own homework or search for anything, I'll spoon-feed you a link: http://tldp.org/LDP/abs/html/ There. Should be AMPLE information to help you write your own shell script. Otherwise, as others have said, post what YOU have written so far, and tell us where you're stuck, and we will HELP you. You will NOT find anyone here to do your work for you, though. |
ACtually it is prohibited to use any loops...and i'm stuck as in if i take 5 aregments...how will sort them or where to start
|
i'm just a beginner and trying hard...its just a week since i touched shell scripting...working in a small company where i was given ths assignment..i finished many programs on my own....regarding this one if i get hint also,it wil help a lot
|
Who said anything about using loops?
Where are you stuck? You need to tell us where you're at, we are not going to write this for you, nor hold your hand through the process. We will provide advice about specific problems you run into while YOU write the script. Start here: http://tldp.org/LDP/abs/html/interna...es.html#APPREF |
I read your initial post and, due to very little linux scripting experience, wasn't even sure it was possible to do without a loop.
So I thought about what might be possible and googled and guess what? I wrote a script to do it and learned some bash in the process. It was quite fun. Your teacher set you this so you would learn commands. Those hours on google were only wasted if you learned nothing. Share what you have done, and what you know, and somebody may help. It helps nobody if someone writes this for you. I'll give you a tip: learn about different ways to access arguments within scripts. |
its not possible to go through all this in one nite....i have to subit tomo
|
They have asked you many times, post what you have done so far and show where you are stuck. Ask specific questions about where you are stuck
|
Quote:
However, if you post what you came up with in those four hours, we might be able to help with that. |
All times are GMT -5. The time now is 10:59 AM. |