zam
June 24, 2018, 11:05pm
1
I would like to find a substitute cp -n command in HP-UX
cp -n
-n, --no-clobber
do not overwrite an existing file \(overrides a previous -i option\)
Thanks
---------- Post updated at 12:35 PM ---------- Previous update was at 11:54 AM ----------
I could not find this info in man pages and yes I can write a function to do this but thought to ask in case I missed something
Would you like to switch on -n
by default or prevent it working at all? I'm not sure which way round you mean.
Perhaps you have scripts that use it, but it doesn't work on HP-UX and you want your scripts to be portable. Is that what you are saying?
Sorry for being confused.
Robin
zam
June 25, 2018, 5:12am
3
Hi, thanks to reply, I meant that I would prefer to use cp -n option or similar switch on HP-UX if there is one as I did it on Linux. But I could not find it on HP-UX. I thought maybe there is something similar that I am just don't know of.
I am just saying that if there is nothing like that on HP-UX I will write a small script for that. And it's not a an issue.
Thanks again
Cheers
"cp -n" is a GNU extension to the POSIX standard "cp" utility .
As it's a platform-specific, non-standard extension, it's not necessarily going to be available on other, non-GNU platforms.
1 Like
wbport
June 25, 2018, 2:05pm
6
If the output file doesn't exist, you are good to go. *
If the output is a directory, check it for the presence of your input file. *
Possible extra check: do you have execute and write permissions in the current or target directory?
RudiC
June 25, 2018, 2:35pm
7
madeingermany:
You can try the trick
cp -i ... < /dev/null
Very nifty trick! You might want to suppress the confirmation question as well:
cp -i . . . </dev/null 2>/dev/null
EDIT: or even cp -i . . . </dev/null 2>&0
?
zam
June 26, 2018, 3:38am
8
Thank everyone you for your replies, yes it works!
---------- Post updated at 05:08 PM ---------- Previous update was at 05:07 PM ----------
I used this one as it suppresses all output cp -i . . . </dev/null 2>&0