Join the lines

Hi All,

Currently, the output looks like this:

hdisk0
queue_depth:3
hdisk1
queue_depth:3
hdisk2
queue_depth:1
hdisk3
queue_depth:1

I need to change the format to look like this:

hdisk0 queue_depth:3
hdisk1 queue_depth:3
hdisk2 queue_depth:1
hdisk3 queue_depth:1

Thanks very much!

nawk 'ORS=(FNR%2)?FS:RS' myFile

Is that output of your script or a flat file? What is generating this output?

for i in `lspv | awk '{print $1}`
do
print $i
lsattr -El $i | grep queue_depth | awk '{print $1 ":" $2}'
done

The output looks like this

hdisk0
queue_depth:3
hdisk1
queue_depth:3
hdisk2
queue_depth:1
hdisk3
queue_depth:1

how can I change to

hdisk0 queue_depth:3
hdisk1 queue_depth:3
hdisk2 queue_depth:1
hdisk3 queue_depth:1

---------- Post updated at 05:04 PM ---------- Previous update was at 04:54 PM ----------

It works perfectly. Thanks so much vgersh99. You're the guru ! :b:

instead of

print $i

you could

echo -n $i

or

for i in `lspv | awk '{print $1}`
do
  attribute=`sattr -El $i | grep queue_depth | awk '{print $1 ":" $2}'`
  print $i $attribute
done

Awesome!

Thanks a lot, peterro

$ sed -n  'N;s/\n/ /p' inputfile
hdisk0 queue_depth:3
hdisk1 queue_depth:3
hdisk2 queue_depth:1
hdisk3 queue_depth:1

cat inputfile|xargs -n 2

or

xargs -n 2 -a inputfile

Pity that OP didn't even try that elegant awk solution rather than the loop in bash with tons of piping!