I've been able to remove all special characters from a fixed length file which appear in the first column but as a result all subsequent columns have shifted to the left by the amount of characters deleted. It is a space separated file. Line 1 in input file is corrupt. Line 2 is what it should look like. The string 000022000362700 starts at position 49 on both lines. The problem I'm having is that after removing the 3 special chars the field moves to position 46.
GAVISCON LIQUID PEPPERMINT �OT 000022000362700 159588000007979400 50001584182 0006S020000 GAVISCON LIQUID PEPPERMINT OT 000022000362700 159588000007979400 50001584182 0006S020000
The command I'm using is as follows :
cat file.txt | grep '[^ - ~]' | sed's/[^ - ~]//g'
This produces following output:
GAVISCON LIQUID PEPPERMINT OT 000022000362700 159588000007979400 50001584182 0006S020000
By removing the special characters every field to the right of the changed field has moved to the left changing the field start positions.
I've been searching for a while now and cannot find any solution for this issue.
How should I proceed?
[^ - ~]
(inclusive spaces)? - What is that supposed to do?