Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added portable sed command for OpenBSD/NetBSD #3257

Closed
wants to merge 2 commits into from

Conversation

nerdy-sam
Copy link

Standard sed, which is used on OpenBSD and NetBSD, doesn't have the "-i" option

Standard sed, which is used on OpenBSD and NetBSD, doesn't have the "-i" option
@mpapis
Copy link

mpapis commented Oct 24, 2014

I just did quick test and I would not be so sure that using tee to the same file is so safe, on larger files you could hit conflict between the read and written content (in my tests tee did not change Inode of the file), wouldn't it be safer to use sed ... < file > file.tmp && mv -f file.tmp file?

@nerdy-sam
Copy link
Author

@mpapis, looks like you're right. If we were wanting to replicate the functionality of the -i option, it requires creating a temp file. This is from the sed manual....

-i[SUFFIX]
--in-place[=SUFFIX]
This option specifies that files are to be edited in-place. GNU sed does this by creating a temporary file and sending output to this file rather than to the standard output

Right now it appears as if sed's buffers are acting as our temp file, --unbuffered would probably give us a blank file.

@mcornella mcornella closed this Jun 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants