H
hukadan
Guest
People even created a command to do that (yes(1)), so I think it is a rather common situation.I am not so sure that many users like this " echo y | mv test mc "
People even created a command to do that (yes(1)), so I think it is a rather common situation.I am not so sure that many users like this " echo y | mv test mc "
-f
option does; mv -f test mc
. Done. No need for these ridiculous constructs. -f Do not prompt for confirmation before overwriting the destination
path. (The -f option overrides any previous -i or -n options.)
-i
and -f
is important. Compare mv -i -f sfile dfile
and mv -f -i sfile dfile
.While I agree on the mv(1) case, my remark was more general : it is not uncommon to feed yes to a command if there is no flag to silence the prompt.No need for these ridiculous constructs.
That I agree with.it is not uncommon to feed yes to a command if there is no flag to silence the prompt.
rm -f file
mv -f file trg
cp -f file trg
unlink -f file
mv -f trg file
cp -f trg file
unlink file
mv trg file
cp trg file
[…]cp
,rm
andmv
all have the same consistent behavior […] By default, no confirmation is asked.-i
requests confirmation when anything would be overwritten or deleted.-f
means "do anything possible" and also overrides-i
.
-f Do not prompt for confirmation before overwriting the destination
path. (The -f option overrides any previous -i or -n options.)
-i Cause mv to write a prompt to standard error before moving a file
that would overwrite an existing file. If the response from the
standard input begins with the character `y' or `Y', the move is
attempted. (The -i option overrides any previous -f or -n
options.)
-f For each existing destination pathname, remove it and create a new
file, without prompting for confirmation regardless of its
permissions. (The -f option overrides any previous -i or -n
options.)
-i Cause cp to write a prompt to the standard error output before
copying a file that would overwrite an existing file. If the
response from the standard input begins with the character `y' or
`Y', the file copy is attempted. (The -i option overrides any
previous -f or -n options.)
-f Attempt to remove the files without prompting for confirmation,
regardless of the file's permissions. If the file does not
exist, do not display a diagnostic message or modify the exit
status to reflect an error. The -f option overrides any previous
-i options.
-i Request confirmation before attempting to remove each file,
regardless of the file's permissions, or whether or not the
standard input device is a terminal. The -i option overrides any
previous -f options.
mv -f ...
cp -f ...
rm -f ...
if [ "x`pidof mc`" = "x" ] ; ...
to make sure that everything is under your control.Actually it's good if a script which is supposed to be run unattended stops working - assuming you log its output to get the info.
It will tell you that something unexpected has happened. If you don't care, just use "-f", however, you may want to add extra checks in your scripts, e.g.if [ "x`pidof mc`" = "x" ] ; ...
to make sure that everything is under your control.
I'll have to grieve you: that script will not run on Linux on ARM! So, it's not even consistent within the same OS!what is a bit of a lack is that the same script will run on Linux, but not on bsd
thank youI'll have to grieve you: that script will not run on Linux on ARM! So, it's not even consistent within the same OS!
thank you for rsync.Do you test rsync?
Exactly which part of rsync is bloat? If you identify a part that is not useful, maybe the author would remove it.thank you for rsync.
I think that it is bloated and unreliable.
Does scp need also a confirmation as well, like mv and cp ?
scp
doesn't have -a option, i.e., in particular, you'll get actual files instead of symlinks. rsync
perfectly works, but... the original question was about mv
, thus those commands won't help you, since eventually you'd like to delete the source file ;-) Also, copy-and-delete is very different from move if the source and target are on the same filesystem.why not just cp ?scp
doesn't have -a option, i.e., in particular, you'll get actual files instead of symlinks.
rsync
perfectly works, but... the original question was aboutmv
, thus those commands won't help you, since eventually you'd like to delete the source file ;-) Also, copy-and-delete is very different from move if the source and target are on the same filesystem.
Indeed, why? You asked about scp, I replied ;-)why not just cp ?
Indeed, why? You asked about scp, I replied ;-)
cd ; gcc helloworld.c -o hello ; ./hello & scp hello localhost:~/hello
I find that annoying in windows but at least you can disable it in UNIX. It's not as annoying when it's just a line in terminal.Does scp need also a confirmation as well, like mv and cp ?
Those security are unnecessary. This is annoying and reminds us Microsoft WIndows with millions popups.