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=— }’