I spent several hours looking at different posts and testing different solutions but none worked. I tried sed, powershell and heard of tr but could not configure/install it correctly.
I receive hundreds of text files to a windows server.
The files with several million records contain lines like these:
123xxxxxNULyyyyaaabbbCRLF
124xxxxxNULzzzzCRLFxxxxxCRLF
Now, I need to load this data to redshift which could not handle NUL and sees CRLF (the one in the middle) as end of line and errors out of missing data.
So, I need to remove NUL global from the file then remove CRLF if it is not at end of line
123xxxxyyyyaaabbbCRLF
124xxxxxzzzzxxxxCRLF
I have seen some posts on removing linefeed with sed but even the syntax would not work on my windows10.
Thanks in advance
I can edit some files in notepad+++ but this wont work on large files and hundreds of them.
I tried some sed I found on a post but errored out.
C:\data>sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' x.txt
sed: -e expression #1, char 1: unknown command: `''
C:\data>sed -e ':a;N;$!ba;s/\n/ /g' x.txt
sed: -e expression #1, char 1: unknown command: `''
C:\data>sed -e :a;N;$!ba;s/\n/ /g x.txt
sed: -e expression #1, char 15: unterminated `s' command
I tried some sed I found on a post but errored out.
C:\data>sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' x.txt
sed: -e expression #1, char 1: unknown command: `''
C:\data>sed -e ':a;N;$!ba;s/\n/ /g' x.txt
sed: -e expression #1, char 1: unknown command: `''
C:\data>sed -e :a;N;$!ba;s/\n/ /g x.txt
sed: -e expression #1, char 15: unterminated `s' command
a simple sed or powershell or else solution that the output file looks like:
123xxxxyyyyaaabbbCRLF
124xxxxxzzzzxxxxCRLF