I use sed command to delete first two lines and last line from a file and i want to redirect the output to the SAME file
EXAMPLE :
sed '1,2d' '$d' pra >pra
this deletes first two lines & last line from the file .But when i try to redirect the output to Same file , an Problem Occurs .
when i open and see the the redirected file pra nothing is present inside the file .
IS there a better way of doing this ..deleting first two lines and last line from a file and and saving it with the same file Name .
To save output to same file, use --in-place or -i modifier.
E.g.
sed -i options_you_want name_of_file_to_change
It's much neater than redirecting to temp files, and then back to original file.
As pointed out below, --in-place may not be available on Solaris...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With