Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-22-2013
Linusolaradm1 Linusolaradm1 is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 29 June 2015, 6:51 PM EDT
Posts: 157
Thanks: 19
Thanked 3 Times in 3 Posts
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 11:58 AM..
Sponsored Links
    #2  
Old Unix and Linux 03-22-2013
PikK45 PikK45 is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 27 July 2015, 2:10 AM EDT
Location: Chennai
Posts: 573
Thanks: 50
Thanked 75 Times in 73 Posts
Can you post sample output of the commands that u used?
Sponsored Links
    #3  
Old Unix and Linux 03-22-2013
Linusolaradm1 Linusolaradm1 is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 29 June 2015, 6:51 PM EDT
Posts: 157
Thanks: 19
Thanked 3 Times in 3 Posts
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 Unix and Linux 03-22-2013
PikK45 PikK45 is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 27 July 2015, 2:10 AM EDT
Location: Chennai
Posts: 573
Thanks: 50
Thanked 75 Times in 73 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"

Linux
The Following User Says Thank You to PikK45 For This Useful Post:
Linusolaradm1 (03-22-2013)
Sponsored Links
    #5  
Old Unix and Linux 03-22-2013
in2nix4life's Unix or Linux Image
in2nix4life in2nix4life is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 23 July 2015, 3:18 PM EDT
Location: East Coast
Posts: 620
Thanks: 1
Thanked 177 Times in 163 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 Unix and Linux 03-22-2013
Linusolaradm1 Linusolaradm1 is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 29 June 2015, 6:51 PM EDT
Posts: 157
Thanks: 19
Thanked 3 Times in 3 Posts
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 Unix and Linux 03-22-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 27 July 2015, 4:48 PM EDT
Location: Galactic Empire
Posts: 3,419
Thanks: 240
Thanked 1,222 Times in 1,148 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 01:01 PM
grep with multiple patterns with multiple arguments jmadden UNIX for Dummies Questions & Answers 2 06-04-2012 10:53 AM
How do you [e]grep for multiple values within multiple files? callumw UNIX Desktop for Dummies Questions & Answers 4 03-18-2012 09:21 PM
Grep multiple strings in multiple files using single command gagan4599 UNIX for Dummies Questions & Answers 2 01-19-2011 06:22 AM
grep command to find multiple strings in multiple lines in a file. ritikaSharma UNIX for Dummies Questions & Answers 2 12-17-2010 03:43 AM



All times are GMT -4. The time now is 06:23 AM.