awk ‘{gsub(/MSH/,”nMSH”);print}’ some_file >temp
puts each message on its own line and stores in file temp
then search or something else
awk ‘/some big reg ex here/’ temp
or to find a field
strings temp >temp1
grep PID temp1 |cut -f 6,20 -d “|”
returns patient_name and ssn from each message in the file