I’m making a script in bash that requires files to be copied. I tried using the cp command with the -n flag set but I found out that on some systems the -n flag is not available.
cp: invalid option -- n
I want this script to be portable enough so that users won’t be required to update their cp.
What the -n flag does is copy only files from the source that are not already in the destination without prompting.
Is there an alternative to this?
If the
-iflag is available,yes n | cp -i ...should achieve the same ascp -n ....