I'm a new learner of shell programming, I have some files coming in with binary data which I need to strip off, but I don't know how. Any help will be appreciated.
Thanks,
The binary data came in across the file. But, the file is always in fixed length file. There are different type of binary data came in each time and we considered those are bad data.
I think what I need is to write a script to strip of all the nonprintable characters, does this make sense?
Thanks so much..
Not guaranteeing this because if you're binary data over writes you EOL, octal \012, you may have a problem reading the data. Here's a small example:
1) Given data file, file.1, which looks like this:
aABCd
tr -dc '\012\101\102\103' < file.1 > new.file
this example says to delete all characters, but
LF - octal \012
A - octal \101
B - octal \102
C - octal \103
new.file should look like:
ABC
lower case a and d were deleted.
Do a man ascii and you'll see a listing of the ascii character set in octal. expand the command I've given you to choose the values you want. You'll probably want to go to \177.
If this doesn't do it, you'll probably have to write a "C" program. Use the low-level open function.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.