Reputation: 361
Let's say I have the following file
asdfa .a
xsf. asdfa
. xasdf
asdfasfd.sadfa.
asdfa .a
xsf. asdfa
. 3xasdf
asdfasfd2.sadfa.
And, I want to get this:
asdfa .a
xsf. asdfa
.xasdf
asdfasfd_sadfa.
asdfa .a
xsf. asdfa
. 3xasdf
asdfasfd2_sadfa.
Basically, every dot has to be replaced with an underscore if all following conditions are true:
Update:
So, far I could only come up with sed 's/\./_/g'
. But, this replaces every dot.
Upvotes: 0
Views: 55
Reputation: 60
I think this should do the trick
sed -i 's/\(\w\)\(\.\)\(\w\)/\1_\3/g' mytextfile.txt
Upvotes: 1