Need to append matching strings in a file

Hi ,

I am writing a shell script to check pvsizes in linux box.

[root@pavan san_migration]#  for i in `cat vgs1`
> do
> echo "########### $i ###########"
> pvs|grep -i $i|awk '{print $2,$1,$5}'>pvs_$i
> pvs|grep -i $i|awk '{print $1}'|while read a
> do
> fdisk -l $a|head -2|tail -1|awk '{print $2,$3}'>pvs_$i1
> done
> cat pvs_$i
> cat pvs_$i1
> done
########### system ###########
system /dev/sda2 39.41g
/dev/sda2: 42.3
[root@pavan san_migration]#

Now i want to merge the output of last lines into single line like below through shell script

system /dev/sda2 39.41g 42.3

can some one help with it.

Just change print to printf in first awk as highlighted above.

paste pvs_$i pvs_$i1
1 Like

replace the file cats with the funky code below ...

cat pvs_$i pvs_$i1 | tr "\n" "\c" | awk -F"[ c]" '{print $1, $2, $3, $5}'
1 Like