LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-10-2015, 08:44 PM   #1
Vigneshjei
LQ Newbie
 
Registered: Jul 2015
Posts: 1

Rep: Reputation: Disabled
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
 
Old 07-10-2015, 10:06 PM   #2
mralk3
Member
 
Registered: May 2015
Posts: 760

Rep: Reputation: 232Reputation: 232Reputation: 232
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/

Last edited by mralk3; 07-11-2015 at 12:32 PM.
 
Old 07-11-2015, 08:24 AM   #3
fatmac
Senior Member
 
Registered: Sep 2011
Location: Surrey/Hants Border, UK
Distribution: BSD & Linux - As long as they are Lightweight
Posts: 1,500

Rep: Reputation: Disabled
You might also like to look at cut &/or awk.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash script: How to assign variable to an sqlite3 command with variable embedded? ninja6o4 Linux - Software 10 02-15-2015 05:43 PM
assign number to interface Ammad Linux - Hardware 1 01-05-2015 09:21 AM
[SOLVED] assign full name to variable then grep a file for the variable socalheel Programming 3 09-16-2013 12:04 PM
[SOLVED] BASH: Assign a variable to a variable name... c_henry Programming 9 06-04-2012 12:33 PM
How do you assign a variable to be a variable file name in a directory? David_Elliott Programming 4 04-14-2009 11:19 AM


All times are GMT -5. The time now is 12:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration