0

I tried sw_vers but it only prints the information to the terminal. I cannot use it, as I have to store it in a variable and then compare.

Based on version I have to move files to appropriate location in file system.

What's the correct way to achieve this?

2
  • Any command that outputs information to a terminal can be used to get that same information into a variable, by setting the variable equal to the command enclosed within back ticks. VAR=`ls` runs the ls command and assigns VAR to the output of it. Commented Jun 12, 2014 at 10:33
  • @mah:thanks for letting me know.I am not a developer who is familiar with the scripting languages,I do development using objective-c.So I wasn't aware of that. Thank you very much again Commented Jun 17, 2014 at 9:37

1 Answer 1

1

This is the way to do it:

v=$(sw_vers -productVersion)

echo $v
10.9.3
Sign up to request clarification or add additional context in comments.

Comments

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.