Misleading (irritating) output from cp
Andrey Repin
anrdaemon@yandex.ru
Fri Jul 4 13:22:26 GMT 2025
Greetings, Fergus Daly!
> If you try
> $ cp -v existingfile existingdirectory
> you get feedback
> 'existingfile' -> 'existingdirectory/existingfile'
> which is just fine. (Omitting the switch -v silences the feedback: also fine.)
> Whereas: if you try
> $ cp -v existingfile nonexistingdirectory
> you get feedback (two lines)
> 'existingfile' -> 'nonexistingdirectory'
> /bin/cp: cannot create regular file: No such file or directory
> of which the 2nd line is useful advice but the 1st line is just a bit
> misleading / irritating / .. difficult to ignore .. whatever.
> (Try the same / similar thing with any other command e.g. rm e.g. md5sum
> and you just get the 2nd line advice.)
> Try
> $ cp -v existingfile nonexistingdirectory 2> /dev/null
> then you suppress line 2 as required; but you still get line 1 which now is
> _very_ misleading / _very_ irritating!
> This "feature" is matched in Linux.
> Maybe a small thing but not to me. (Where it occurs it rather screws up the smooth evolution of session logs.)
> Does anybody know of a way of suppressing the 1st line feedback?
If you know for a fact that the destination directory may not exist, you
should use `install` instead of `cp`.
It provides greater control over a file/directory creation.
--
With best regards,
Andrey Repin
Friday, July 4, 2025 16:21:14
Sorry for my terrible english...
More information about the Cygwin
mailing list