0

I have some tables for which I need to replace a field that has a random position in each table.

For information, the table are semicolon separated fields and I would like to replace the field "datum" by "YEAR-MONTH-DAY".

So far, I have tried:

sed -i 's/datum/YEAR-MONTH-DAY/g' input > output

But it just outputs an empty file.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
steve
  • 548

1 Answers1

2

As steeldriver astutely pointed out in the comments, you've told sed to -i edit the file in-place. As a result, sed will not provide any output, and so the > redirection will put that nothing into the output file.

Either keep the -i flag and accept that the input file will be updated in-place:

sed -i 's/datum/YEAR-MONTH-DAY/g' input

or drop the -i flag and use the redirection to put the updated contents in the output file:

sed    's/datum/YEAR-MONTH-DAY/g' input > output
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255