Tar of directory

i have a 10 directory in my path
i have to take a tar of 7 directory without link files and also have to exclude those 3 directory.

tar -cvzf /path/file_name.tar.gz directoryname

please help!!
facing problem in excluding links file

I'm afraid you are not being clear in your needs. Are you saying that under /path there are 10 directories, 1, 2, 3....9 & 10 and you only want to back up seven of them?

If so then you just add the directories you want to the list at the end of the tar command, so if we want 1, 2, 3, 5, 6, 7 & 9 we can run this:-

tar -cvzf /path/file_name.tar.gz /path/1 /path/2 /path/3 /path/5 /path/6 /path/7 /path/9

Indeed if the list is that simple, you can:-

tar -cvzf /path/file_name.tar.gz /path/[1235679]

..... but that is unlikely unless your directories have a specific name structure that you can match with an expression.

Some versions of tar allow an exclude or include list, e.g. AIX has the -L flag which is followed by a file containing the items to work with. To explore this further, please tell us the OS version an level.

I hope that this helps and that I haven't missed the point.

Robin
Liverpool/Blackburn
UK

thanx for d reply
but

I don't want to take links file in tar which is under folder 1.

Either:

tar -cvzf /path/file_name.tar.gz /path/{subdir1,subdir2,subdir5...} 

OR

tar -cvzf /path/file_name.tar.gz /path/ --exclude file2

Currently on Windows, so Argumentname might not be proper.

This is assuming a compatible version of tar which is why I've asked for the OS version and level. No point in confusing things so soon. :mad:

It might the best answer, or it may just get in the way.

Robin