Grep multiple values | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Grep multiple values

UNIX for Dummies Questions & Answers


Tags
grep, lvm

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-22-2013
Linusolaradm1 Linusolaradm1 is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 21 November 2014, 9:44 PM EST
Posts: 126
Thanks: 11
Thanked 1 Time in 1 Post
Grep multiple values

This


Code:
for i in /dev/disco/*;do lvdisplay $i|grep -i size;done

Return me every size of lvm in vg "disco"
I want to return me,the size and the name of lvm,how to do this?
Thanks

Last edited by radoulov; 03-22-2013 at 12:58 PM..
Sponsored Links
    #2  
Old 03-22-2013
PikK45 PikK45 is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 26 November 2014, 5:10 AM EST
Location: Chennai
Posts: 567
Thanks: 43
Thanked 74 Times in 72 Posts
Can you post sample output of the commands that u used?
Sponsored Links
    #3  
Old 03-22-2013
Linusolaradm1 Linusolaradm1 is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 21 November 2014, 9:44 PM EST
Posts: 126
Thanks: 11
Thanked 1 Time in 1 Post
Sure

Code:
  LV Size                31,00 GiB
  LV Size                30,00 GiB
  LV Size                70,00 GiB
  LV Size                31,00 GiB
  LV Size                31,00 GiB
  LV Size                2,00 GiB
  LV Size                10,00 GiB
  LV Size                50,00 GiB
  LV Size                80,00 GiB
  LV Size                31,00 GiB
  LV Size                3,95 TiB
  LV Size                32,00 GiB
  LV Size                32,00 GiB
  LV Size                5,00 GiB

    #4  
Old 03-22-2013
PikK45 PikK45 is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 26 November 2014, 5:10 AM EST
Location: Chennai
Posts: 567
Thanks: 43
Thanked 74 Times in 72 Posts
I meant to ask for the output of lvdisplay .

Sorry for not being clear.

If your command gives you out multiple lines, then you can use egrep -i "size|name"

The Following User Says Thank You to PikK45 For This Useful Post:
Linusolaradm1 (03-22-2013)
Sponsored Links
    #5  
Old 03-22-2013
in2nix4life's Avatar
in2nix4life in2nix4life is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 21 November 2014, 1:51 PM EST
Location: East Coast
Posts: 611
Thanks: 1
Thanked 176 Times in 162 Posts
Also, you should be able to do away with the for loop and just feed the path to the lvdisplay command to list all the LVs in that VG and then pipe it to the grep\egrep command:


Code:
lvdisplay /dev/disco/* | egrep command

Sponsored Links
    #6  
Old 03-22-2013
Linusolaradm1 Linusolaradm1 is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 21 November 2014, 9:44 PM EST
Posts: 126
Thanks: 11
Thanked 1 Time in 1 Post
Last question..for order it with awk?

I obtain


Code:
  LV Name                slackware5
  LV Size                32,00 GiB
  LV Name                slackware6
  LV Size                32,00 GiB

i want

Code:
  LV Name   slackware5  LV Size    32,00 GiB
                LV Name   slackware6  LV Size    32,00 GiB
etc etc..

How to do with awk?
Thanks
Sponsored Links
    #7  
Old 03-22-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 26 November 2014, 4:40 PM EST
Location: Galactic Empire
Posts: 3,389
Thanks: 236
Thanked 1,210 Times in 1,136 Posts

Code:
awk '/LV Name/{ORS=FS}/LV Size/{ORS=RS}1'

The Following User Says Thank You to Yoda For This Useful Post:
Linusolaradm1 (03-22-2013)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep multiple strings in multiple files xshang Shell Programming and Scripting 7 11-05-2012 02:01 PM
grep with multiple patterns with multiple arguments jmadden UNIX for Dummies Questions & Answers 2 06-04-2012 11:53 AM
How do you [e]grep for multiple values within multiple files? callumw UNIX Desktop for Dummies Questions & Answers 4 03-18-2012 10:21 PM
Grep multiple strings in multiple files using single command gagan4599 UNIX for Dummies Questions & Answers 2 01-19-2011 07:22 AM
grep command to find multiple strings in multiple lines in a file. ritikaSharma UNIX for Dummies Questions & Answers 2 12-17-2010 04:43 AM



All times are GMT -4. The time now is 03:10 PM.