Thursday, 23 August 2012

Linux command line file editing

Use 'tr' to replace NULL characters (^@) from files:

# tr '\000' '\n' < input.txt > output.txt

Use 'sed' to remove blank lines (^$ matches a blank line, 'd' = delete line):

# sed '/^$/d' input.txt > output.txt

or use 'grep':

# grep -v '^$' input.txt > output.txt

No comments:

Post a Comment