• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

using sed to edit a file

lightweight

Senior member
I have my expression written and it works when I send the output to a new file:
ex: sed 'expression' input > output

What I want to do is just use: sed 'expression' input

I don't want to rename the file, I just want the operation to be performed on that file. All it does is delete lines that match a certain criteria. How can I do this?
 
i am at work and dont have time to look up stuff and work is xp so no man pages either - but here goes:

Are you trying to save the changes in the original file? and if you try that via redirection, does it give you an empty file? try using man and see if there is a -i option and use that . I recently did that and pretty sure it was sed but cant check right now - will be able to this evening - so try something like this

sed 'expression' -i inputFile
 
Output to a different file and move the changed file. Or copy the input file to a temp file and run sed on it. Its more portable this way.
 
Back
Top