0

Use awk to combine lines

Problem: We have a text file containing individual records spanning multiple lines. We want to combine them into one line each.

For example, given:

fs001d1
VERSION: 8.12.10
fsams001
VERSION: 8.13.7
fsams04p
VERSION: 8.13.8
fsams05p
VERSION: 8.13.8
fsams06p
VERSION: 8.13.8

We want:

fs001d1 VERSION: 8.12.10
fsams001 VERSION: 8.13.7
fsams04p VERSION: 8.13.8
fsams05p VERSION: 8.13.8
fsams06p VERSION: 8.13.8

cat output | awk ‘{d=d”"$o}
/VERSION/ {
print d
d=”"
}’

jlim0930

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.