Wednesday, February 8, 2012

AWK: convert lines in a file to columns


#!/bin/bash

awk '

/Name:/, /Zip:/ { printf "%s ", $0 }
/Zip:/ { print "" }

' <<EOT
Name: John Doe
Age: 32
Zip: 60324
Name: Jane Doe
Age: 34
Zip: 54930
Name: Skippy
Age:134
Zip:23456
EOT

No comments: