+2 votes
in Operating Systems by (11.1k points)
I have created CSV files by downloading data from MQ SQL server tables. When I tried to load the CSV files to PostgreSQL, it complained about the null character (x'00') and newline (\r\n) . I am using Python code to replace these bad characters, which seems a bit slow. How can I remove those characters using a Linux command?

1 Answer

0 votes
by (15.7k points)

Try 'tr' command with -d option.

Usage: tr [OPTION]... SET1 [SET2]
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
  -d, --delete            delete characters in SET1, do not translate

E.g.

tr -d '\000\r'   < cost/COST.csv > COST_n.csv

...