1752811 Members
6004 Online
108789 Solutions
New Discussion юеВ

Re: format text

 
SOLVED
Go to solution
nightwish
Advisor

format text

Hi

how can i format the text below whithout blank lines???

/dev/vg00/lvol7
/dev/vg00/lv52
/dev/vg00/lvol4
/dev/vg00/lvol5
/dev/vgwsx/lvol1
/dev/vg00/lvol6
/dev/vg00/lvoltib
/dev/vg00/lvol9
/dev/vgws_mpbe/lvol1

/dev/vgws_mpbe/lvol2

/dev/vgws_mpbe/lvol3

/dev/vgws_mpbe/lvol4

/dev/vgws_mpbe/lvol5

/dev/vgws_mpbe/lvol6

/dev/vgws_mpbe/lvolWS


regards .. I appreciated some help :)
3 REPLIES 3
Ivan Ferreira
Honored Contributor
Solution

Re: format text

Use:

cat file | grep -v ^$

command | grep -v ^$

The grep command in this case display all lines that ARE NOT blank lines. (^$) means the start of the line and the end of the line, that is, the start and end are together, with no info between.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
nightwish
Advisor

Re: format text

Thanks ...


Just the best..
Jared Middleton
Frequent Advisor

Re: format text

Another option is sed, as in:
sed '/^$/d' < myfile
or
{command} | sed '/^$/d'