Results 1 to 3 of 3
Hi All,
i am new to scripting
i have a file : file.dat with following data
Code:
STORAGE PERCENTAGE FLAG:
/storage_01 64% 0
/storage_02 17% 1
/storage_03 10% 0
/storage_04 ...
- 12-14-2010 #1Just Joined!
- Join Date
- Dec 2010
- Posts
- 5
Get a field value corresponding to another field value
Hi All,
i am new to scripting
i have a file : file.dat with following data
Code:
STORAGE PERCENTAGE FLAG:
/storage_01 64% 0
/storage_02 17% 1
/storage_03 10% 0
/storage_04 50% 1
I need to get the value of PERCENTAGE in a variable for a value of storage passed as variable
i have tried the following without success like :
Please guide me on this..Code:percentage='awk -vx="$defaultStorage" '{FS=OFS=" "}$1==x{print $2}1' file.dat
Thanks in advance
- 12-14-2010 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Something like this:
Code:defaultStorage="storage_02" percentage=$(awk -vx="$defaultStorage" '$1 ~ x{print $2}' file.dat)
- 12-15-2010 #3Just Joined!
- Join Date
- Dec 2010
- Posts
- 5
Thank you...


Reply With Quote