Suner Evren
Suner Evren

Reputation: 63

How to clear unwanted characters in bash

Actually I have a problem that I can not resolve. Below is partial content of my file:

      Slot  Type                     S/N                Version  FPGA version
        1   1 port XFP               0229052008000033   A00           4
--- more --- ^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H        2   4 port 10/100            0138052008000008   D03          10

You can see there are unwanted characters which are causing parsing to fail. I am parsing this file with a bash script. I want to get rid of this unwanted characters. I could not find a way to do that with sed

Does anybody has a kind of experience? I will really appreciate if he can share with me the way to clear them.

Thanks

Upvotes: 0

Views: 73

Answers (1)

Малъ Скрылевъ
Малъ Скрылевъ

Reputation: 16514

For examplle with :

echo "2---/@@w##z"|sed 's/[^A-Za-z0-9\s\/]//g'
# 2/wz

Upvotes: 1

Related Questions