From: rvaede on 25 May 2010 17:48 I have a main subdirectory and a bunch of subdirectories. I wanted to copy files from all the subdirectories that start with 2009* as the file name to another location. I wanted to also create the directories in the destination location. Example: Source MainDirectory directory1 (has 2009* and 2010* files) directory2 (has 2009* and 2010* files) directory3 (has 2009* and 2010* files) directory4 (has 2009* and 2010* files) directory5 (has 2009* and 2010* files) Destination Directory1 (includes 2009* files) Directory2 (includes 2009* files) Directory3 (includes 2009* files) Directory4 (includes 2009* files) Directory5 (includes 2009* files)
From: Andrew McDermott on 26 May 2010 04:28 rvaede wrote: > > I have a main subdirectory and a bunch of subdirectories. > I wanted to copy files from all the subdirectories that start with > 2009* as the file name to another location. > I wanted to also create the directories in the destination location. > > Example: > > Source > MainDirectory > > directory1 (has 2009* and 2010* files) > directory2 (has 2009* and 2010* files) > directory3 (has 2009* and 2010* files) > directory4 (has 2009* and 2010* files) > directory5 (has 2009* and 2010* files) > > Destination > > Directory1 (includes 2009* files) > Directory2 (includes 2009* files) > Directory3 (includes 2009* files) > Directory4 (includes 2009* files) > Directory5 (includes 2009* files) in the main directory: find . -depth -name '2009*' -print | cpio -pmdv /path/to/Destination You may be able to do something similar with pax but I don't know that command. Andrew
From: rvaede on 26 May 2010 10:11 On May 26, 4:28 am, Andrew McDermott <a.p.mcderm...(a)NOSPAM-rl.ac.uk> wrote: > rvaede wrote: > > > I have a main subdirectory and a bunch of subdirectories. > > I wanted to copy files from all the subdirectories that start with > > 2009* as the file name to another location. > > I wanted to also create the directories in the destination location. > > > Example: > > > Source > > MainDirectory > > > directory1 (has 2009* and 2010* files) > > directory2 (has 2009* and 2010* files) > > directory3 (has 2009* and 2010* files) > > directory4 (has 2009* and 2010* files) > > directory5 (has 2009* and 2010* files) > > > Destination > > > Directory1 (includes 2009* files) > > Directory2 (includes 2009* files) > > Directory3 (includes 2009* files) > > Directory4 (includes 2009* files) > > Directory5 (includes 2009* files) > > in the main directory: > > find . -depth -name '2009*' -print | cpio -pmdv /path/to/Destination > > You may be able to do something similar with pax but I don't know that > command. > > Andrew- Hide quoted text - > > - Show quoted text - Well Done Andrew. Thank you
From: Michael Paoli on 29 May 2010 10:08 On May 26, 1:28 am, Andrew McDermott <a.p.mcdermott(a)NOSPAM-rl.ac.uk> wrote: > rvaede wrote: > > > I have a main subdirectory and a bunch of subdirectories. > > I wanted to copy files from all the subdirectories that start with > > 2009* as the file name to another location. > > I wanted to also create the directories in the destination location. > > > Example: > > > Source > > MainDirectory > > > directory1 (has 2009* and 2010* files) > > directory2 (has 2009* and 2010* files) > > directory3 (has 2009* and 2010* files) > > directory4 (has 2009* and 2010* files) > > directory5 (has 2009* and 2010* files) > > > Destination > > > Directory1 (includes 2009* files) > > Directory2 (includes 2009* files) > > Directory3 (includes 2009* files) > > Directory4 (includes 2009* files) > > Directory5 (includes 2009* files) > > in the main directory: > > find . -depth -name '2009*' -print | cpio -pmdv /path/to/Destination > > You may be able to do something similar with pax but I don't know that > command. > > Andrew Similarly with tar(1): $ (cd source_directory && tar -cf - . | (cd target_directory && tar - xpf -)) Notes: o cpio will typically also include additional file types, e.g. character and block special device files, and with suitable privileges, also create them, whereas many versions of tar won't o find -print and cpio won't work with filenames (of any type) that contain newline in the filename, whereas tar and GNU find -print0 and GNU cpio -0 will work in such cases
|
Pages: 1 Prev: ANSI terminal escape sequence regexp Next: \w|while read line |