Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to check disks used for mirror in lvs. currently I am using "lslv -m ulv" command but to check for multiple lvs is difficult. I guess there should be some option in grep to exclude repetition of word, because if I will grep "disk" it will show a number of rows.

share|improve this question
add comment

1 Answer

the command that you need is uniq. Supply the output from grep through uniq

grep disk | uniq

Update:

 ~ > cat test
0001 0201 hdisk0
0002 0202 hdisk0
0003 0203 hdisk0
0004 0204 hdisk0
 ~ > cat test | cut -d " " -f 3 | sort -u
hdisk0
 ~ >

I assume you do not need the first two column if the only thing you want to sort by is hdisk0

share|improve this answer
    
Sorry, but It did not work. lslv -m salvaglv | grep hdisk0 | uniq. it should give only one row with hdisk0. but insted it gave me same output as lslv -m salvaglv | grep hdisk0. –  Hemant Oct 3 '12 at 8:43
    
Ok. Please try to use sort -u instead of uniq. Also if you could show us the output of lslv -m salvaglv | grep hdisk0 it could shed some light on by which columns you should sort. –  mnmnc Oct 3 '12 at 8:55
    
hemantr:stelsvr> lslv -m salvaglv | grep hdisk0 0001 0201 hdisk0 0002 0202 hdisk0 0003 0203 hdisk0 0004 0204 hdisk0 0005 0205 hdisk0 0006 0206 hdisk0 0007 0207 hdisk0 0008 0208 hdisk0 0009 0209 hdisk0 0010 0210 hdisk0 0011 0211 hdisk0 0012 0212 hdisk0 /u/hemantr hemantr:stelsvr> lslv -m salvaglv | grep hdisk0 | sort -u 0001 0201 hdisk0 0002 0202 hdisk0 0003 0203 hdisk0 0004 0204 hdisk0 0005 0205 hdisk0 0006 0206 hdisk0 0007 0207 hdisk0 0008 0208 hdisk0 0009 0209 hdisk0 0010 0210 hdisk0 0011 0211 hdisk0 0012 0212 hdisk0 /u/hemantr hemantr:stelsvr> –  Hemant Oct 3 '12 at 12:32
    
i've updated my answer. I assume you do not need the information from first two columns if you want to see only one entry for hdisk0. –  mnmnc Oct 3 '12 at 12:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.