0

I want to build a shell script. There should be a conditional flag for CentOS version. I want to set a variable for that version like this

VERSION := $(lsb_release -sr)

But when I included this part I got error. Please someone help me to get the version in shell script.

N.B : lsb_release sr works fine when I give this command in terminal.

3
  • 2
    It's uname -r. Why is this tagged c++? Commented May 14, 2013 at 5:24
  • 1
    because I am compiling a C++ code in shell script. Commented May 14, 2013 at 5:28
  • 1
    I only need the version like 5.6, 6.3 etc Commented May 14, 2013 at 5:29

2 Answers 2

1

In shell script:

VERSION=$(lsb_release -sr) or VERSION=$(/usr/bin/lsb_release -sr) with full path.

will store the release value in $VERSION. What error are you getting ??

Sign up to request clarification or add additional context in comments.

3 Comments

Did you try as said above ??
yup. I have written both suggestions.
Did bash say incorrect ?? what is the output : echo $SHELL
1

Try this command

uname -r

-r, --kernel-release     print the kernel release

In my case it is showing only 2.6.39

Or try yourself as uname --help for appropriate choice for you.

2 Comments

ok thanks... will you write a line, what you should have been done for writing in shell script? my problem is there. I think I am doing wrong in shell script.
i think you are doing right..i am not so good in shell script..just check this or try this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.