--excludeoption; but none of them resolved the problem and syntax were different everywhere.
Within inches from going for the alternative approach, of listing files and directories to be included, and passing it on to tar as source; My colleague's search came with another approach, and it finally worked.
Lets cut to the chase and see how to resolve this problem:
The best way is to create a list of all the directories to be excluded in a file, one entry per row with no extra spaces towards end, and pass it as an parameter to tar.
Here goes the Syntax:
tar cvfX path_of_the_tar path_of_the_exclude_file path_of_directory_to_tar
Let’s first create a file with all directories we want to exclude:
$ cat excluded-files.txt
Now just use the syntax with the file name which created earlier:
$ tar cvfX test.tar excluded-files.txt test
a test/ 0K
a test/a excluded
a test/b/ 0K
a test/b/ba excluded
a test/b/bb/ 0K
a test/b/bb/bba.txt 0K
a test/c/ 0K
a test/c/ca/ 0K
a test/c/ca/caa 0K
a test/c/cc/ 0K
a test/c/cc/cca 0K
If you see excluded in the verbose output; you are done!!!