0

sed: 1: "filename": bad flag in substitute command: 'l'

sed throws this when i am trying to change some substring:

sed -i '/string1/ s/string2/string3/g' filename
fedorqui
  • 275,237
  • 103
  • 548
  • 598
  • 2
    (1) Show us the command that you were actually using, not the phony command with the `string1`, `string2` etc. (2) Are you on linux, as the tag says, or are you on OSX? – John1024 Aug 09 '16 at 08:03
  • sed -i '/rate="100"/ s/tax="15"/tax="25"/g' this is the actual command I used and I am on OSX – Finn is missing Aug 10 '16 at 06:05
  • 1
    Try: `sed -i "" '/rate="100"/ s/tax="15"/tax="25"/g'` – John1024 Aug 10 '16 at 06:08
  • 1
    The [`-i` option is being used incorrectly](https://stackoverflow.com/documentation/sed/3640/in-place-editing/12529/portable-use). `sed -i '' '/string1/ s/string2/string3/g' filename` will have the intended behavior, but note that the manual warns against using the `-i` option without creating a backup file. – kdhp Aug 10 '16 at 06:24

0 Answers0