3

I am trying to eliminate 3 first lines in every *.sql file for which I run the following command:

sed -i '1,3d' *.sql

It eliminates the lines with the side effect that after each character I get a symbol with 00 code (^a)

Why is this happening and how do I get rid of those symbols?

Here is a screenshot of what it becomes:

screenshot of resulting file

  • eliminate first 3 lines – Roman Goyenko Oct 24 '17 at 16:48
  • I added a screenshot – Roman Goyenko Oct 24 '17 at 17:01
  • try running dos2unix *.sql before the sed command. – DopeGhoti Oct 24 '17 at 17:04
11

You're editing a UTF16 file with an eight-bit aware utility.

Either convert the file using something like iconv or find a UTF16 aware utility to remove the first three lines of each file.

iconv --from-code=UTF16 --to-code=UTF8 < file16.txt > file8.txt
  • that was it, I actually regenerated the files in ascii and it worked as expected. Thanks! – Roman Goyenko Oct 24 '17 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.