Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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 mean its ok if the question appears on google...actually i wasted 4 hrs on it and developed a headache...pls help
Spell out your words. And do you really expect us to believe that you spent 4 hours searching on Google, and did not come across ONE bash scripting tutorial???
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.
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
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.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,672
Rep:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.