I know it is possible to exclude a particular folder by a command like this:
tar --exclude='/srv/www/project/node_modules' -zcvf /backup/project.tgz .
My question how to exclude any folder named node_modules
anywhere within the entire /srv/www
directory, to exclude it and exclude all folders under it?
node_modules
in their names likenode_modules123
andnode_modules_new
etc. then append a*
to the excluded directory name and use the command like sotar -zcvf /backup/project.tar.gz --exclude "/srv/www/project/node_modules*" /srv/www/
and please edit your question and make it clear. Thank you--exclude
option, the syntax of the filename must match the path being tared. In your example, the exclude option should be--exclude=./srv/www/project/node_modules
in order for the match to occur and the directory to be excluded