Due to a Hard disk problem I am trying to shift a partition from one hard disk to another. I am following http://www.ibm.com/developerworks/library/l-partplan.html article to do that. In the copying part I would like to ignore one particular sub directory. How can I accomplish that keeping in mind when copying I have to preserve my owner group and time stamp. There is around 700 GB of data that needs to be copied if I do not ignore a particular subdirectory.
Normally I use
cpio as follows,
cd source_dir; find . -depth | cpio -pdmv dest_dir
And since this is a pipeline you can put a "subtraction filter" in the middle.
cd sourcedir; find . -depth | grep -v exclude_dir | cpio -pdmv dest_dir
or you could split this is into several steps,
cd source_dir; find . -depth > files.lst gedit files.lst # (take out the offending directory and files and save back to files.lst) cpio -pdmv dest_dir < files.lst
Of course I'd test this on something smaller first but you get the idea.
You could write a simple bash script with a loop to ignore the certain path you don't want copied and copy the rest. Another solution could be to us regular expressions. You can read up on bash scripting here -> http://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html Regex tutorial here -> http://www.regular-expressions.info/