HI, I have made a script abc.sh, now i want it to display its version when i run it. suppose im running script, ./abc.sh -v, i want it to d
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
HI, I have made a script abc.sh, now i want it to display its version when i run it. suppose im running script, ./abc.sh -v, i want it to d
HI,
I have made a script abc.sh, now i want it to display its version when i run it.
suppose im running script, ./abc.sh -v, i want it to display its version number.
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Rep:
Quote:
Originally Posted by nisha.bhatt007@gmail.com
HI,
I have made a script abc.sh, now i want it to display its version when i run it.
suppose im running script, ./abc.sh -v, i want it to display its version number.
OK, you say you have made "a script", but you don't show us what it is. You need to post it, along with your efforts to resolve your issue(s).
I don't mean to be rude, but we don't do people's homework for them. We are happy to help you where you get stuck, but we expect that you have made at least some effort of you're own.
Can you post your efforts and use CODE tags when posting scripts - so it's easy to read it.
I've asked for this to moved to the Programming forum.
A shell script is only plain readable English text. If the script does not store or refer to a version number store somewhere else, there is clearly no way it can display the version number. Also the version number is not stored in the file header.
Yes, either getopts() or positional parameters will do the job of collecting run time options which you can use. I'm throwing in some links there since they are hard to find in all the noise in the search engines these days.
I have made a script abc.sh, now i want it to display its version when i run it.
suppose im running script, ./abc.sh -v, i want it to display its version number.
Hi nisha.bhatt007,
Please post a copy of your script as well as what you intend to say when the version request argument is used.
Please also take a look at the advice offered by other members about parsing script options.
Do you understand how to output information when you have parsed an option and then need to inform the user about the script version?
In the future, it will be helpful to provide more details of your question.
agree, define "it" so one can show you how to assign/obtain the version to it so it can show its version to the user. get it?
it is implying the scripts version, did you by any chance use an echo command in your script, and use a variable assignment? maybe put the two ideas together and see what you come up with.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.