extracting desired value from cmd o/p

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extracting desired value from cmd o/p
# 1  
Old 08-14-2009
extracting desired value from cmd o/p


I m using vxassist cmd to get avaialbe space in DG o/p is like this, wat I need is only numeric value of the o/p , I have a solution is anyone can provide better

x1# vxassist -g appdg1 maxsize
Maximum volume size: 90406912 (44144Mb)

I need only 44144 value command I m using rite now is

x1# vxassist -g appdg1 maxsize | awk '{print $5}' | cut -f1 -d")" | sed -e 's/(//' | sed -e 's/Mb//'


# 2  
Old 08-14-2009
Above string can be parsed using sed like below

$  echo "Maximum volume size: 90406912 (44144Mb)"|sed 's/\(.*(\)\([0-9].*\)\(Mb.*\)/\2/'

# 3  
Old 08-14-2009
quiet a complex syntax , if u don't mind ranjith could please explain wat exactly this syntax is doing

I try digging man pages wasn't successful


# 4  
Old 08-14-2009
no need of such complex sed for this..
echo "Maximum volume size: 90406912 (44144Mb)"|awk -F"[(Mb)]" '{print $3}'

# 5  
Old 08-14-2009
not working o/p is blank now

1:ksh# vxassist -g appdg1 maxsize |awk -F"[(Mb)]" '{print $3}'

# 6  
Old 08-14-2009
working fine..
fnsonlu1-/home/fnsonlu1> echo "Maximum volume size: 90406912 (44144Mb)"|awk -F"[(Mb)]" '{print $3}'

# 7  
Old 08-14-2009
In sed we can give sub patterns like \(pattern\) and I have sub divided your data 'Maximum volume size: 90406912 (44144Mb)' into three sub patterns

1. Maximum volume size: 90406912 ( - \(.*(\)
this will represent data the from beginning of the data to '('
2. 44144 - \([0-9]*\)
this will represent coninuous occurance of digits after '('
3. Mb) - \(Mb.*\)
this will represent the data from Mb to end of line

and I have used \2 to print only the second pattern.

sed 's/\(.*(\)\([0-9].*\)\(Mb.*\)/\2/'


Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Desired Date format

I need to get the current year for the files that has been created today. Ex- when i list in unix console it shows ls -l abc.txt -rw-rw-r-- 1 user1 user1 33 May 2 08:58 abc.txt but i need to get as May 2 2013 , i dont need 08:58 is there any command to list it out in that... (7 Replies)
Discussion started by: Prashanth B
7 Replies

2. UNIX for Dummies Questions & Answers

Help me in getting the desired result

Hi All, I have input file which is pipe delimited A | 1 B | 2 c | 3I need output of displaying total number of lines in a file as last column. A | 1 | 3-----total number of linesin file. B | 2 | 3 c | 3 | 3 (9 Replies)
Discussion started by: pravinashwin
9 Replies

3. Shell Programming and Scripting

Perl open(CMD, "cmd |"); buffering problem..

Hello, There's a third-party application's command that shows the application's status like "tail -f verybusy.log". When use the command, the output comes every 1-sec. but when it goes in a script below the output comes every 8-sec...What is the problem and how can I fix it? open(CMD,... (2 Replies)
Discussion started by: Shawn, Lee
2 Replies

4. Shell Programming and Scripting

need to get the desired output

Below is the my cide which is working fine but I am not getting the output indesired format.there is some problem in alignment.Can someone help me to correct this? if ]; then summary=$( echo -e "Please review the log file of auto coloclean utility.\n"; echo -e... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

5. Shell Programming and Scripting

Extracting duplicates from a desired field

Hello, I have a file of group names and GID's (/etc/group) and I want to find the duplicate group names and put them in a file. So there are 2 fields, i.e.: audit 10 avahi 70 avahi-autoipd 103 bellrpi 605 bin 1 bin 2 bord 512 busobj 161 bwadm 230 cali81 202 card 323 cardiff 901 cbm... (2 Replies)
Discussion started by: mgb
2 Replies

6. Shell Programming and Scripting

Unix cmd prompt how to get old cmd run?

Hi, I am using SunOS I want to serch my previous command from unix prompt (like on AIX we can search by ESC -k) how to get in SunOs urgent help require. (10 Replies)
Discussion started by: RahulJoshi
10 Replies

7. HP-UX

Desired Format !

Hi everybody, I just need desired ouput from text file which should have folowing format; "2007-06-25 00:03:32.926+05:30",12354369,"Load","Completed","Rs.-5,556.00",9452217714 "2007-06-25 00:06:57.357+05:30",12354371,"Load","Completed","Rs.-56.00",9415766266 "2007-06-25... (1 Reply)
Discussion started by: prasanth_babu
1 Replies

8. Shell Programming and Scripting

Help me in getting the desired output

I wanted to put "|" this sign at starting and at end of every field but its not working with first field like Currently the out put is : abc | abc | abc | xyz | xyz | xyz | But I want the out put in this form: | abc | abc | abc | | xyz | xyz | xyz | plz help me. (2 Replies)
Discussion started by: akash
2 Replies

9. Shell Programming and Scripting

Script not working as desired

Reborg, Sorry to bother you. I have tried the code you suggested and it's not creating new files after they satisfy the criteria. If any of the files don't satisfy the criteria it should not create the files at all. Please see my output below. (39 Replies)
Discussion started by: mhssatya
39 Replies

10. UNIX for Dummies Questions & Answers

man <cmd> >> cmd.txt

I've noticed most of my postings here are because of syntax errors. So I want to begin compiling a large txt file that contains all the "man <cmd>" of the commands I most have problems with. I ran a "man nawk >> nawk.txt" but it included a header/footer on each "page". Anyone know how I'd be... (6 Replies)
Discussion started by: yongho
6 Replies
Login or Register to Ask a Question