Monday, April 23, 2012

FreeBSD sed -i Error "sed: 1: "FILE": bad flag in substitute command: '.' "

On FreeBSD if you use the "-i" flag with sed you must specify a backup file.  The simple fix, if you don't want a backup file is to use "" (two quotes, no space between them).  You could also use any other filename you wished.

BAD: sed -i s/ file.txt
GOOD: sed -i "" s/ file.txt

No comments: