Divide an EBCDIC files into multiple files based on value at 45-46 bytes

Hi All,
I do have an EBCDIC file sent from the z/os , this file has records with different record types in it, the type of record is identified by bytes 45-46 like
value 12 has employee record
value 14 has salaray record and etc....

we do now want to split the big ebcdic file into multiple EBCDIC files with unique record type ...
e.g. all the records with value 12 in 45-46 byte go to separate EBCDIC file.. and etc.

How can I achieve this ?

And then send the files back?
Are the Z/OS commands so hard to learn?

Not sure how many record types you have, this solution works if it's only a few just add more >(awk ...) args to the tee command

dd if=infile conv=ascii 2> /dev/null | tee >(
awk 'substr($0,44,2)=="12"' | dd of=employee.out conv=ebcdic 2> /dev/null ) >(
awk 'substr($0,44,2)=="15"' | dd of=customer.out conv=ebcdic 2> /dev/null ) |
awk 'substr($0,44,2)=="14"' | dd of=salary.out   conv=ebcdic 2> /dev/null
1 Like

Amazing, no temp file and not even a while loop!