sed awk tr etc
Posted 01-15-2013 at 06:33 AM by NullTerminator
Updated 01-18-2013 at 06:54 AM by NullTerminator (add sed cmd for non prinitng char)
Updated 01-18-2013 at 06:54 AM by NullTerminator (add sed cmd for non prinitng char)
Tags awk, blob, raspberrypi, sed, translate
A couple sample to strip unreadable characters from a binary file
# replace a bad character in a file
0xa0 is a 'non breaking space' that appears often when cutting and pasting code from
a web page. Especially in some light weight browser like raspberry pi
Code:
# Translate junk characters into newlines while squeezing C:\Temp>tr -sc '[\011\012\015\040-\176]' \n < blob_of_data.txt # Translate and discard single character lines C:\Temp>tr -sc '[\011\012\015\040-\176]' \n < blob_of_data.txt | awk "length($0) > 1"
0xa0 is a 'non breaking space' that appears often when cutting and pasting code from
a web page. Especially in some light weight browser like raspberry pi
Code:
sed 's/'`echo "0xa0"1`'/ /g' <infile > outfile
Total Comments 0