Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> FreeBSD sed doesn't have the in-place editing that GNU sed has

FWIW, that's not correct. On BSD (incl macOS), the -i option takes an argument for the file extension to use as a tmp file:

So for GNU sed:

  sed -i 's/old/new/g' FILE
Translates to BSD sed as:

  sed -i '' 's/old/new/g' FILE
It is not recommended to use an empty string as the extension, but as long as your sed command does not fail due to disk space etc, it is fine.

Also, GNU sed takes an extension argument too, but it is optional:

   sed -iEXT 's/old/new/g' FILE


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: