I've been trying to copy a entire folder to another and this it's simply adding the -r
option
cp -r sourceFolder destFolder
But now i need exclude some files from sourceFolder. How achieve this?
I've been trying to copy a entire folder to another and this it's simply adding the -r
option
cp -r sourceFolder destFolder
But now i need exclude some files from sourceFolder. How achieve this?
You can do something like this
for f in sourceFolder/*
do
if [ "f$" != "filename-to-exclude1" ] || [ "f$" != "filename-to-exclude2" ] # || ...can be extended
then
cp -r f$ destinationFolder # this will copy files and folders regardless so if you need to exclude a file from a subfolder you need to extend that if then structure
fi
done