'without backup file'에 해당되는 글 1건

  1. 2010.08.11 [SED] edit in place without backup

[SED] edit in place without backup

CS/Shell/Perl/Python 2010. 8. 11. 16:20

man page:
-i 
extension
: Edit files in-place, saving backups with the specified extension. 
: If a zero-length extension is given, nobackup will be saved. It is not recommended to give a zero-length extension when in-place editing files, asyou risk corruption or partial content in situations where disk space is exhausted, etc.

-i 를 사용할 경우 extension이 지정되어야 하므로
$ sed -i -e 's/string/sub/' file
과 같이 사용할 경우 extension이 없어 error가 발생한다.

따라서, 다음과 같이
$ sed -i '' -e 's/string/sub/' file
zero-length extension을 지정하여 백업 파일을 생성하지 않고 in place editing을 할 수 있다.
: