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.

Examples:
BAD: sed -i s/192.168.1.1/192.168.1.44/g file.txt
GOOD: sed -i "" s/192.168.1.1/192.168.1.44/g file.txt

No comments: