LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Assign a number to variable (https://www.linuxquestions.org/questions/linux-newbie-8/assign-a-number-to-variable-4175547719/)

Vigneshjei 07-10-2015 07:44 PM

Assign a number to variable
 
Hi,
I am working on getting the memory of my box and assigning it to a variable

I need commands to use both in linux and solaris box.

the problem i am facing is ,when try to assign the out of below , i am not able to do it

-bash-3.2$ sar -r 5 1

SunOS hostname 5.10 Generic_150400-16 sun4v 07/11/2015

00:42:17 freemem freeswap
00:42:22 373643 47222800



now i need to store the value 373643 (first value of the output) to a variable.....

Please suggest some ideas

mralk3 07-10-2015 09:06 PM

Assign a number to variable
 
Please refer to the following link for a very basic explanation of bash variables.

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-5.html

It's a relatively short document, and I recommend reading the whole thing. I also recommend reading the Advanced Bash Scripting guide, here:

http://www.tldp.org/LDP/abs/html/

fatmac 07-11-2015 07:24 AM

You might also like to look at cut &/or awk.


All times are GMT -5. The time now is 11:44 AM.