Skip/remove non-ascii character with sed

sed -i 's/[^[:print:]]//' FILENAME

Also, this acts like dos2unix


This might work for you (GNU sed):

echo "Chip,Dirkland,DrobæSphere Inc,[email protected],usa" |
sed 's/\o346/a+e/g'
Chip,Dirkland,Droba+eSphere Inc,[email protected],usa

Then do what you have to do and after to revert do:

echo "Chip,Dirkland,Droba+eSphere Inc,[email protected],usa" | 
sed 's/a+e/\o346/g'
Chip,Dirkland,DrobæSphere Inc,[email protected],usa

If you have tricky characters in strings and want to understand how sed sees them use the l0 command (see here). Also very useful for debugging difficult regexps.

echo "Chip,Dirkland,DrobæSphere Inc,[email protected],usa" | 
sed -n 'l0'
Chip,Dirkland,Drob\346Sphere Inc,[email protected],usa$

Tags:

Sed