LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   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 (https://www.linuxquestions.org/questions/programming-9/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-4175630202/)

nisha.bhatt007@gmail.com 05-22-2018 02:38 AM

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.

jsbjsb001 05-22-2018 02:52 AM

Quote:

Originally Posted by nisha.bhatt007@gmail.com (Post 5857804)
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.

TenTenths 05-22-2018 04:20 AM

Look at
Code:

getopts
for handling options, or if you want something highly simplistic just look at Positional Parameter handling.

AnanthaP 05-22-2018 04:56 AM

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.

OK

Turbocapitalist 05-22-2018 05:45 AM

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.

rtmistler 05-22-2018 07:16 AM

Quote:

Originally Posted by nisha.bhatt007@gmail.com (Post 5857804)
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.

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.

BW-userx 05-22-2018 09:35 AM

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.


All times are GMT -5. The time now is 10:53 PM.