The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-04-2008
chittiprasad15 chittiprasad15 is offline
Registered User
 

Join Date: Nov 2007
Posts: 2
Smile How to store values into variable in perl

Hi,

Can you please help me of how to store the values into variables.

Here is the output in LINUX for the below command.

$free

output :
total used free
Mem: 3079276 3059328 19948
Swap: 1023992 6324 1017668

while i am trying the below commands i got the ouput
free |grep "Mem:" |awk ' {print $2}'
output for the above cmd is printing == 3079276

similar to the swap as well..

But i want to store the ouput value in a variable

I also decalred the variable like this

$Memory=`free |grep "Mem:" |awk ' {print $2}'`;
print "$Memory ";
It is printing like this
Mem: 3079276 3059328 19948

Can anyone please help me regarding this how to store the values into variables....
Reply With Quote
Forum Sponsor