Converting hex value 7C (for pipe) to CRLF in Unix

I am trying to convert a txt file that includes one long string of data. The lines are separated with hex value 7C (for pipe).

I am trying to process this file using SQR (Peoplesoft) so I thought the easiest thing to do would be to replace the eol char with a CRLF in unix so I can just process as a regular text file in sqr.

The command I am using below replaces EVERY 7 with a ^M and EVERY C with a line feed. What I need, is to replace '7C' with newline or CRLF.

tr '7C' '\r\n' < orig.txt > new.txt

I also tried using sed
sed "s/7C/\n/g" orig.txt > new.txt

but it would only replace 7C with an 'n' and not the line feed that I needed. I have looked at the other threads posted and tried just about all of the suggestions......still no luck so far.

Using tr, can I make the 7C LOOK LIKE 1 character somehow instead of 2? If I could, I would just use the new line (\n) to replace it with.

I would really appreciate your help :slight_smile:

Thanks,
Sharon

tr converts characters, not strings.

Use single quotes and a literal pipe:

sed 's/|/\n/g' orig.txt > new.txt

Yes, I was able to use tr or sed with the | and both worked fine - I replaced with \n in both cases................the only problem is, the file comes in with the hex value for the pipe so I need to be able to convert from 7C to line feed.

sed 's/7C/\n/g'

I actually did try that exact command and for some reason, it will only replace the 7C with n (not line feed)

sed 's/7C/\n/g'

So, I think I'll do this in 2 steps instead of trying to do it in one:

sed 's/7C/|/g'
tr '|' '\n'

thanks for your help :slight_smile: