how to not-delete-a-file with some-command file.txt [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
Can I make `cut` change a file in place?
6 answers
What are the shell's control and redirection operators?
3 answers
I've done this before, expect to mutate a file in place, something like $ tr 't' ',' <file.txt >file.txt
and well, clearly the >
redirection truncates the file before <
can read it;
How do I mutate a file inplace without truncating/deleting it?
bash shell
marked as duplicate by Stephen Kitt, Timothy Martin, ThorSummoner, ilkkachu
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 6 at 20:54
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
 |Â
show 4 more comments
up vote
0
down vote
favorite
This question already has an answer here:
Can I make `cut` change a file in place?
6 answers
What are the shell's control and redirection operators?
3 answers
I've done this before, expect to mutate a file in place, something like $ tr 't' ',' <file.txt >file.txt
and well, clearly the >
redirection truncates the file before <
can read it;
How do I mutate a file inplace without truncating/deleting it?
bash shell
marked as duplicate by Stephen Kitt, Timothy Martin, ThorSummoner, ilkkachu
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 6 at 20:54
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
<s>I didn't see anything about how to operate on-place with < > or <> operators in that question, thanks for the link! Very helpful, but I did not find a useful or equivalent question/answer there to my specific question :bow:</s> Specifically the answer unix.stackexchange.com/a/186126/61349 posted that there is basically no good way to do inplace mutations, either use a temporary file or a different file
â ThorSummoner
Jun 6 at 20:46
2
@ThorSummoner: You can't do what you are trying to do.
â Jesse_b
Jun 6 at 20:47
2
The second answer to that question should provide all the information you need.
â Stephen Kitt
Jun 6 at 20:47
argh, that one (Scott's answer there) is a good answer, but the question doesn't really indicate that subject at all...
â ilkkachu
Jun 6 at 20:49
also: Can I makecut
change a file in place?, Modify a file without creating another file, Wait for stdout stream to finish and then add its contents to a file
â ilkkachu
Jun 6 at 20:51
 |Â
show 4 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Can I make `cut` change a file in place?
6 answers
What are the shell's control and redirection operators?
3 answers
I've done this before, expect to mutate a file in place, something like $ tr 't' ',' <file.txt >file.txt
and well, clearly the >
redirection truncates the file before <
can read it;
How do I mutate a file inplace without truncating/deleting it?
bash shell
This question already has an answer here:
Can I make `cut` change a file in place?
6 answers
What are the shell's control and redirection operators?
3 answers
I've done this before, expect to mutate a file in place, something like $ tr 't' ',' <file.txt >file.txt
and well, clearly the >
redirection truncates the file before <
can read it;
How do I mutate a file inplace without truncating/deleting it?
This question already has an answer here:
Can I make `cut` change a file in place?
6 answers
What are the shell's control and redirection operators?
3 answers
bash shell
asked Jun 6 at 20:39
ThorSummoner
1,08741327
1,08741327
marked as duplicate by Stephen Kitt, Timothy Martin, ThorSummoner, ilkkachu
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 6 at 20:54
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Stephen Kitt, Timothy Martin, ThorSummoner, ilkkachu
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 6 at 20:54
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
<s>I didn't see anything about how to operate on-place with < > or <> operators in that question, thanks for the link! Very helpful, but I did not find a useful or equivalent question/answer there to my specific question :bow:</s> Specifically the answer unix.stackexchange.com/a/186126/61349 posted that there is basically no good way to do inplace mutations, either use a temporary file or a different file
â ThorSummoner
Jun 6 at 20:46
2
@ThorSummoner: You can't do what you are trying to do.
â Jesse_b
Jun 6 at 20:47
2
The second answer to that question should provide all the information you need.
â Stephen Kitt
Jun 6 at 20:47
argh, that one (Scott's answer there) is a good answer, but the question doesn't really indicate that subject at all...
â ilkkachu
Jun 6 at 20:49
also: Can I makecut
change a file in place?, Modify a file without creating another file, Wait for stdout stream to finish and then add its contents to a file
â ilkkachu
Jun 6 at 20:51
 |Â
show 4 more comments
<s>I didn't see anything about how to operate on-place with < > or <> operators in that question, thanks for the link! Very helpful, but I did not find a useful or equivalent question/answer there to my specific question :bow:</s> Specifically the answer unix.stackexchange.com/a/186126/61349 posted that there is basically no good way to do inplace mutations, either use a temporary file or a different file
â ThorSummoner
Jun 6 at 20:46
2
@ThorSummoner: You can't do what you are trying to do.
â Jesse_b
Jun 6 at 20:47
2
The second answer to that question should provide all the information you need.
â Stephen Kitt
Jun 6 at 20:47
argh, that one (Scott's answer there) is a good answer, but the question doesn't really indicate that subject at all...
â ilkkachu
Jun 6 at 20:49
also: Can I makecut
change a file in place?, Modify a file without creating another file, Wait for stdout stream to finish and then add its contents to a file
â ilkkachu
Jun 6 at 20:51
<s>I didn't see anything about how to operate on-place with < > or <> operators in that question, thanks for the link! Very helpful, but I did not find a useful or equivalent question/answer there to my specific question :bow:</s> Specifically the answer unix.stackexchange.com/a/186126/61349 posted that there is basically no good way to do inplace mutations, either use a temporary file or a different file
â ThorSummoner
Jun 6 at 20:46
<s>I didn't see anything about how to operate on-place with < > or <> operators in that question, thanks for the link! Very helpful, but I did not find a useful or equivalent question/answer there to my specific question :bow:</s> Specifically the answer unix.stackexchange.com/a/186126/61349 posted that there is basically no good way to do inplace mutations, either use a temporary file or a different file
â ThorSummoner
Jun 6 at 20:46
2
2
@ThorSummoner: You can't do what you are trying to do.
â Jesse_b
Jun 6 at 20:47
@ThorSummoner: You can't do what you are trying to do.
â Jesse_b
Jun 6 at 20:47
2
2
The second answer to that question should provide all the information you need.
â Stephen Kitt
Jun 6 at 20:47
The second answer to that question should provide all the information you need.
â Stephen Kitt
Jun 6 at 20:47
argh, that one (Scott's answer there) is a good answer, but the question doesn't really indicate that subject at all...
â ilkkachu
Jun 6 at 20:49
argh, that one (Scott's answer there) is a good answer, but the question doesn't really indicate that subject at all...
â ilkkachu
Jun 6 at 20:49
also: Can I make
cut
change a file in place?, Modify a file without creating another file, Wait for stdout stream to finish and then add its contents to a fileâ ilkkachu
Jun 6 at 20:51
also: Can I make
cut
change a file in place?, Modify a file without creating another file, Wait for stdout stream to finish and then add its contents to a fileâ ilkkachu
Jun 6 at 20:51
 |Â
show 4 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
You cannot. The >
redirect operator will create a new empty file as part of the pipeline. Tools (like sed --in-place
) which appear to do so are creating a new file, writing to it, and moving the new file in place of the old one:
$ ls -i file; sed --in-place 's/foo/bar/' file; ls -i file
266110 file
262180 file
yeah, in effect you will always need some kind of journal if you want to mutate the file contents in place, and it just so happens that if the working set fits in memory, and you have no power failures interruptions, you can get away with using the source file in memory as the effective journal :shrug: atleast thats how I put words to it
â ThorSummoner
Jun 6 at 20:57
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You cannot. The >
redirect operator will create a new empty file as part of the pipeline. Tools (like sed --in-place
) which appear to do so are creating a new file, writing to it, and moving the new file in place of the old one:
$ ls -i file; sed --in-place 's/foo/bar/' file; ls -i file
266110 file
262180 file
yeah, in effect you will always need some kind of journal if you want to mutate the file contents in place, and it just so happens that if the working set fits in memory, and you have no power failures interruptions, you can get away with using the source file in memory as the effective journal :shrug: atleast thats how I put words to it
â ThorSummoner
Jun 6 at 20:57
add a comment |Â
up vote
0
down vote
You cannot. The >
redirect operator will create a new empty file as part of the pipeline. Tools (like sed --in-place
) which appear to do so are creating a new file, writing to it, and moving the new file in place of the old one:
$ ls -i file; sed --in-place 's/foo/bar/' file; ls -i file
266110 file
262180 file
yeah, in effect you will always need some kind of journal if you want to mutate the file contents in place, and it just so happens that if the working set fits in memory, and you have no power failures interruptions, you can get away with using the source file in memory as the effective journal :shrug: atleast thats how I put words to it
â ThorSummoner
Jun 6 at 20:57
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You cannot. The >
redirect operator will create a new empty file as part of the pipeline. Tools (like sed --in-place
) which appear to do so are creating a new file, writing to it, and moving the new file in place of the old one:
$ ls -i file; sed --in-place 's/foo/bar/' file; ls -i file
266110 file
262180 file
You cannot. The >
redirect operator will create a new empty file as part of the pipeline. Tools (like sed --in-place
) which appear to do so are creating a new file, writing to it, and moving the new file in place of the old one:
$ ls -i file; sed --in-place 's/foo/bar/' file; ls -i file
266110 file
262180 file
answered Jun 6 at 20:54
DopeGhoti
39.8k54779
39.8k54779
yeah, in effect you will always need some kind of journal if you want to mutate the file contents in place, and it just so happens that if the working set fits in memory, and you have no power failures interruptions, you can get away with using the source file in memory as the effective journal :shrug: atleast thats how I put words to it
â ThorSummoner
Jun 6 at 20:57
add a comment |Â
yeah, in effect you will always need some kind of journal if you want to mutate the file contents in place, and it just so happens that if the working set fits in memory, and you have no power failures interruptions, you can get away with using the source file in memory as the effective journal :shrug: atleast thats how I put words to it
â ThorSummoner
Jun 6 at 20:57
yeah, in effect you will always need some kind of journal if you want to mutate the file contents in place, and it just so happens that if the working set fits in memory, and you have no power failures interruptions, you can get away with using the source file in memory as the effective journal :shrug: atleast thats how I put words to it
â ThorSummoner
Jun 6 at 20:57
yeah, in effect you will always need some kind of journal if you want to mutate the file contents in place, and it just so happens that if the working set fits in memory, and you have no power failures interruptions, you can get away with using the source file in memory as the effective journal :shrug: atleast thats how I put words to it
â ThorSummoner
Jun 6 at 20:57
add a comment |Â
<s>I didn't see anything about how to operate on-place with < > or <> operators in that question, thanks for the link! Very helpful, but I did not find a useful or equivalent question/answer there to my specific question :bow:</s> Specifically the answer unix.stackexchange.com/a/186126/61349 posted that there is basically no good way to do inplace mutations, either use a temporary file or a different file
â ThorSummoner
Jun 6 at 20:46
2
@ThorSummoner: You can't do what you are trying to do.
â Jesse_b
Jun 6 at 20:47
2
The second answer to that question should provide all the information you need.
â Stephen Kitt
Jun 6 at 20:47
argh, that one (Scott's answer there) is a good answer, but the question doesn't really indicate that subject at all...
â ilkkachu
Jun 6 at 20:49
also: Can I make
cut
change a file in place?, Modify a file without creating another file, Wait for stdout stream to finish and then add its contents to a fileâ ilkkachu
Jun 6 at 20:51