Home Man
Search
Today's Posts
Register

HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

Recursive copy of Folders with files

Tags
hp-ux

👤 Login to reply

 
Thread Tools Search this Thread
# 15  
Old 09-08-2014
Why don't you run it in chunks as tar cvpf - fd000{001..050}/reports
# 16  
Old 09-08-2014
Hi RudiC, thanks for the tips.

I tried this to try with 2 folders (fd000010 & fd000011)

Code:
#tar cvpf - fd000{010..011}/reports | { cd test-copy/ && tar xvpf - ; }

But it is giving error

Code:
/SQArun>tar cvpf - fd000{010..011}/reports | { cd test-copy/ && tar xvpf - ; }
tar: cannot open fd000{010..011}/reports
/SQArun/test-copy>cd


Last edited by vbe; 09-08-2014 at 07:43 AM.. Reason: code tags please not icow
# 17  
Old 09-08-2014
Too bad - that's a brace pattern available in recent shells. Try setting the braceexpand (-B) option (ksh).
# 18  
Old 09-08-2014
Lightbulb

You could try it with filename expansion this way:
Code:
#following should match directories fd000100 to fd000109
tar cvpf - fd00010?/reports | { cd test-copy/ && tar xvpf - ;}

#following should match directories fd000100 to fd000199
tar cvpf - fd0001??/reports | { cd test-copy/ && tar xvpf - ; }

If the above fails, you could try it with this approach for running it in chunks:
Code:
#first, create a temporary list with all relevant directories:
$ ls -d fd* > dirlist

#get first two entries (fd000100 & fd000101)
$ awk 'NR==1,NR==2' dirlist
fd000100
fd000101
$

#combine it with tar command 
$ awk 'NR==1,NR==2' dirlist | while read dir
 do
 tar cvpf - $dir/reports | { cd test-copy/ && tar xvpf - ; }
 done

If it works, then you take bigger chunks, eg. 'NR==1,NR==100', then 'NR==101,NR==200' and so on.
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to copy files/folders and show the files/folders? Imre Shell Programming and Scripting 6 10-24-2016 08:16 AM
Recursive search for files and copy to new directories flyawaymike Shell Programming and Scripting 3 06-30-2012 03:08 PM
Loop folders, delete files, copy new ones acraig Shell Programming and Scripting 6 01-18-2011 05:37 PM
copy mutilple files to mutiple folders M474746 UNIX for Dummies Questions & Answers 4 01-10-2011 11:20 AM
recursive saving of files and folders terrid Shell Programming and Scripting 4 12-14-2010 08:08 AM
Windows mass copy files with same name in differnt folders jville Windows & DOS: Issues & Discussions 5 10-07-2010 03:17 PM
I need script Copy permissions of files and folders from one server to another ave-phoenix Shell Programming and Scripting 11 08-19-2010 08:46 AM
copy some files from users home folders to my folder pcrana Shell Programming and Scripting 3 08-18-2009 08:16 AM
copy all files and folders and cjange or remove ownership misterm UNIX for Dummies Questions & Answers 3 09-01-2008 06:29 PM
recursive copy of hidden files usfrog UNIX for Advanced & Expert Users 2 02-19-2002 02:16 PM


All times are GMT -4. The time now is 03:49 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password