user1543042
user1543042

Reputation: 3440

sed replace eating non-matching paterns

I'm trying to do a simple sed replace but I'm getting a strange result. I just want to take any of my conditions that end in .0_ and replace them with . However, something unexpected is occurring. It's eating anything of the form "x0". What do I need to change here?

$ cat test.csv
    Ar_phi_2.5_eV_tOn_0.5_ns_tOff_20_ns_d_3.2_um_V_20_V,4586.516493
    Ar_phi_2.5_eV_tOn_0.5_ns_tOff_20_ns_d_3.2_um_V_20.0_V,4586.516493
$ sed -i -- 's|.0_|_|g' test.csv ;
$ cat test.csv
    Ar_phi_2.5_eV_tOn_0.5_ns_tOff__ns_d_3.2_um_V__V,4586.516493
    Ar_phi_2.5_eV_tOn_0.5_ns_tOff__ns_d_3.2_um_V_20_V,4586.516493

Upvotes: 2

Views: 40

Answers (1)

alexverh
alexverh

Reputation: 56

Try change

sed -i -- 's|.0_|_|g'

to

sed -i -- 's|\.0_|_|g'

Upvotes: 4

Related Questions