0

I have a table like the "input table" below and I want to keep the tab separation after the incremental operation to a specific cell in the second column (line with Paul, third shown, in example). I tried this comand awk 'BEGIN {FS="\t"} NR==675 {$2++}; {print $0}' table, but the tab saparator of the edited line is being replaced by space, like shown in the "output table" below.

Input table:

...
Watson  1
Carry   1
Paul    1
John    1
...

Output table:

...
Watson  1
Carry   1
Paul 2
John    1
...
Jorge Eduardo
  • 193
  • 1
  • 3
  • 11
  • 2
    `FS=OFS="\t"` should do it. OFS=OuputFieldSeparator. Good luck. – shellter Aug 14 '17 at 02:09
  • It works! Thank you, shellter! `awk 'BEGIN {FS=OFS="\t"} NR==675 {$2++}; {print $0}' table` – Jorge Eduardo Aug 14 '17 at 02:34
  • the default `OFS` value is the space char. There is quite alot you can do with `awk` in regards to `FS`,`OFS`,`RS` and `ORS`. See the tutorial at https://grymoire.com/Unix/Awk.html`. Good luck. – shellter Aug 14 '17 at 03:32

0 Answers0