Prevent overwriting a file with redirection
up vote
0
down vote
favorite
if I do:
$ node foo.js > output.d.ts
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
bash shell-script shell
add a comment |
up vote
0
down vote
favorite
if I do:
$ node foo.js > output.d.ts
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
bash shell-script shell
What shell are you using?
– AlexP
2 days ago
I am using the bash shell thx
– Alexander Mills
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
if I do:
$ node foo.js > output.d.ts
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
bash shell-script shell
if I do:
$ node foo.js > output.d.ts
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
bash shell-script shell
bash shell-script shell
asked 2 days ago
Alexander Mills
2,10211237
2,10211237
What shell are you using?
– AlexP
2 days ago
I am using the bash shell thx
– Alexander Mills
2 days ago
add a comment |
What shell are you using?
– AlexP
2 days ago
I am using the bash shell thx
– Alexander Mills
2 days ago
What shell are you using?
– AlexP
2 days ago
What shell are you using?
– AlexP
2 days ago
I am using the bash shell thx
– Alexander Mills
2 days ago
I am using the bash shell thx
– Alexander Mills
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
Yes, there is the noclobber
option:
Prevent output redirection using
>
,>&
, and<>
from overwriting existing files.
$ echo foo > bar
$ echo foo > bar
$ set -o noclobber
$ echo foo > bar
bash: bar: cannot overwrite existing file
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
Yes, there is the noclobber
option:
Prevent output redirection using
>
,>&
, and<>
from overwriting existing files.
$ echo foo > bar
$ echo foo > bar
$ set -o noclobber
$ echo foo > bar
bash: bar: cannot overwrite existing file
add a comment |
up vote
3
down vote
accepted
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
Yes, there is the noclobber
option:
Prevent output redirection using
>
,>&
, and<>
from overwriting existing files.
$ echo foo > bar
$ echo foo > bar
$ set -o noclobber
$ echo foo > bar
bash: bar: cannot overwrite existing file
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
Yes, there is the noclobber
option:
Prevent output redirection using
>
,>&
, and<>
from overwriting existing files.
$ echo foo > bar
$ echo foo > bar
$ set -o noclobber
$ echo foo > bar
bash: bar: cannot overwrite existing file
is there a way to configure the shell to do not overwrite the file if it already exists? Maybe a no-clobber option?
Yes, there is the noclobber
option:
Prevent output redirection using
>
,>&
, and<>
from overwriting existing files.
$ echo foo > bar
$ echo foo > bar
$ set -o noclobber
$ echo foo > bar
bash: bar: cannot overwrite existing file
answered 2 days ago
Michael Homer
44.8k7117156
44.8k7117156
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483122%2fprevent-overwriting-a-file-with-redirection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What shell are you using?
– AlexP
2 days ago
I am using the bash shell thx
– Alexander Mills
2 days ago