-1

Input:

7058    7067    7111    7186    7288    7322    7328    7373
./. ./. ./. ./. ./. 0|0 ./. 0|0
./. ./. 0|0 ./. ./. 0|0 ./. 0|0
./. ./. ./. ./. ./. 0|0 ./. 0|0
./. ./. ./. ./. ./. 0|0 ./. 1|1

Desired output:

7058    7067    7111    7186    7288    7322    7328    7373
-1  -1  -1  -1  -1  0|0 -1  0|0
-1  -1  0|0 -1  -1  0|0 -1  0|0
-1  -1  -1  -1  -1  0|0 -1  0|0
-1  -1  -1  -1  -1  0|0 -1  1|1

I have tried sed -i 's/././-1/g' File_name but it didn't work.

nickgryg
  • 25,567
  • 5
  • 77
  • 79
Waqas Khokhar
  • 159
  • 1
  • 11

2 Answers2

1

An expression for that:

sed -E 's,./.,-1,g' <(echo './.')

You can use delimiters different from /, so you don't have to escape them, . doesn't have to be excaped if you are using extended regular expressions.

Possible delimiters(there may be others):

  • :
  • _
  • ,
  • |

So in your case:

sed -E -i.backup 's,./.,-1,g' File_name

, or you are able to escape .-s and /-s, but that can lead to a mess:

sed -i.backup 's/\.\/\./-1/g' File_name

Please use an extension name after the i flag to make a backup file if you're not sure about the result of the sed command.

ntj
  • 171
  • 12
0
sed -r 's:./.:-1:g' File_name

=> 7058 7067 7111 7186 7288 7322 7328 7373 -1 -1 -1 -1 -1 0|0 -1 0|0 -1 -1 0|0 -1 -1 0|0 -1 0|0 -1 -1 -1 -1 -1 0|0 -1 0|0 -1 -1 -1 -1 -1 0|0 -1 1|1

adc
  • 771
  • 4
  • 12