Grep multiple values


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep multiple values
# 1  
Old 03-22-2013
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..
# 2  
Old 03-22-2013
Can you post sample output of the commands that u used?
# 3  
Old 03-22-2013
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
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"

Smilie
This User Gave Thanks to PikK45 For This Post:
# 5  
Old 03-22-2013
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

# 6  
Old 03-22-2013
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
# 7  
Old 03-22-2013
Code:
awk '/LV Name/{ORS=FS}/LV Size/{ORS=RS}1'

This User Gave Thanks to Yoda For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading multiple values from multiple lines and columns and setting them to unique variables.

Hello, I would like to ask for help with csh script. An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Discussion started by: FMMOLA
7 Replies

2. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

3. Shell Programming and Scripting

Grep from multiple patterns multiple file multiple output

Hi, I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command. Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns. Xargs -I {} grep... (3 Replies)
Discussion started by: Diya123
3 Replies

4. Shell Programming and Scripting

Grep multiple strings in multiple files

Hi, every one! I have a file with multiple strings. file1 ATQRGNE ASQGVKFTE ASSQYRDRGGLET SPEQGARSDE ASSRDFTDT ASSYSGGYE ASSYTRLWNTGE ASQGHNTD PSLGGGNQPQH SLDRDSYNEQF I want to grep each string in hundreds of files in the same directory, further, I want to find out the string... (7 Replies)
Discussion started by: xshang
7 Replies

5. UNIX Desktop Questions & Answers

How do you [e]grep for multiple values within multiple files?

Hi I'm sure there's a way to do this, but I ran out of caffeine/talent before getting the answer in a long winded alternate way (don't ask ;) ) The task I was trying to do was scan a directory of files and show only files that contained 3 values: I940 5433309 2181 I tried many variations... (4 Replies)
Discussion started by: callumw
4 Replies

6. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

Hi, I will use below command for grep single string ("osuser" is search string) ex: find . -type f | xarg grep -il osuser but i have one more string "v$session" here i want to grep in which file these two strings are present. any help is appreciated, Thanks in advance. Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies

7. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

8. Shell Programming and Scripting

grep two values together.

Hi... I have a file abc.txt , havin more then 10,000 lines, each field separated by '#'. I want to grep 9914699895 and 999 from abc.txt I am trying cat abc.txt | grep 9914699895 | grep 999 but i am also getting data like 9991111111 or 9991010101 I want to grep "999" exactly and... (1 Reply)
Discussion started by: tushar_tus
1 Replies

9. UNIX for Dummies Questions & Answers

grep using ASCII values

machine: HPUX file: a.dat contents: decimal 1 decimal 2 string 1 string 2 ASCII value of 'd': 100. to grep lines that have 'd', I use the following command grep d a.dat My requirement: I should grep for lines that contain 'd'. But I should use ASCII value of 'd' in the command... (1 Reply)
Discussion started by: sriksama
1 Replies

10. Shell Programming and Scripting

grep a list of values

Hi everybody! :) :D :D :) it's great to be here since this is my first post. touch /base/oracle/FRA/XMUT00/RMAN_FLAG touch /base/oracle/FRA/XRLL00/RMAN_FLAG find directory name containing RMAN_FLAG : $ find /base/oracle/FRA -name RMAN_FLAG -print|xargs -n1 dirname |sort -u... (3 Replies)
Discussion started by: jolan_louve
3 Replies
Login or Register to Ask a Question