Unix/Linux Go Back    


HP-UX 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

HP-UX


Closed    
 
Thread Tools Search this Thread Display Modes
    #15  
Old Unix and Linux 09-08-2014   -   Original Discussion by mhbd
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 17 June 2018, 2:22 PM EDT
Location: Aachen, Germany
Posts: 12,891
Thanks: 427
Thanked 3,962 Times in 3,644 Posts
Why don't you run it in chunks as tar cvpf - fd000{001..050}/reports
Sponsored Links
    #16  
Old Unix and Linux 09-08-2014   -   Original Discussion by mhbd
mhbd's Unix or Linux Image
mhbd mhbd is offline
Registered User
 
Join Date: Jul 2005
Last Activity: 24 November 2014, 6:04 AM EST
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #17  
Old Unix and Linux 09-08-2014   -   Original Discussion by mhbd
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 17 June 2018, 2:22 PM EDT
Location: Aachen, Germany
Posts: 12,891
Thanks: 427
Thanked 3,962 Times in 3,644 Posts
Too bad - that's a brace pattern available in recent shells. Try setting the braceexpand (-B) option (ksh).
    #18  
Old Unix and Linux 09-08-2014   -   Original Discussion by mhbd
junior-helper's Unix or Linux Image
junior-helper junior-helper is offline
Registered User
 
Join Date: Aug 2014
Last Activity: 28 June 2017, 4:04 PM EDT
Posts: 344
Thanks: 37
Thanked 126 Times in 114 Posts
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.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
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
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 08:02 PM.