4 ms·
what is wrong with the '-i' option? -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if SUFFIX supplied)
by samoa42 6y ago
what is wrong with the '-i' option?
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if SUFFIX supplied)
- 1vuio0pswjnm7 6y agosed -i creates a temp file. Needs additional storage space the size of the file. This can pose a problem with large files on smaller computers with limited storage and memory. In the past, some BSD seds (other than FreeBSD) did not have the -i option. Also worth noting that "sponge", unlike sed, apparently reads the entire file into memory. For a large file, this would require enough RAM to fit the entire file.
- uberduper 6y agoTry `sed -i ""` to avoid creating a backup.
- 1vuio0pswjnm7 6y agoWhen you use sed -i, a temporary file is always created. Using FreeBSD as an example, see references to "tmpfname" in main.c: https://raw.githubusercontent.com/freebsd/freebsd/master/usr.bin/sed/main.c https://raw.githubusercontent.com/freebsd/freebsd/master/usr... The naming scheme differs between seds. GNU prefixes the name with "sed" while BSD encloses it between two "!"'s. To see the name of the temporary file on BSD, something like ktrace sed -i 's/foo/bar/' file kdump ktrace.out|sed -n '/NAMI/p'