Sponsored Content
Top Forums Shell Programming and Scripting How to recursively copy directory only for recent files? Post 302971133 by RudiC on Saturday 16th of April 2016 04:40:20 AM
Old 04-16-2016
List the results - don't cp yet. Then, go through the list, separate the directories from the path, and use mkdir -p to create it. Then only you can copy...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Recursively copy only specific files from a directory tree

Hi I am a shell-script newbie and am looking to synchronize certain files in two directory structures. Both these directory-trees are in CVS and so I dont want the CVS directory to be copied over. I want only .sh and .pl files in each subdirectory under these directory trees to be... (3 Replies)
Discussion started by: sharpsharkrocks
3 Replies

2. Shell Programming and Scripting

delete files recursively in the specified directory

I have to write a shell script which can delete all the files and directories recursively inside the specified directory but should not delete the specified directory. Please some body help me in writing the script. (3 Replies)
Discussion started by: deepthi.s
3 Replies

3. Shell Programming and Scripting

Recursively search for most recent modification

Hello all, I'm trying to determine when the last time a file in a certain directory was modified. I don't care what file it is, I just want to know when it was last updated. So far I have ls -aRl --full-time --sort=time which is close. The problem is that it only sorts within folders, not... (2 Replies)
Discussion started by: lokisapocalypse
2 Replies

4. Shell Programming and Scripting

Copy only files recursively

Hi, find . | xargs -s 47518 can list all the files and directories recursively , is there any possibility to copy only files from directories and subdirectoreis once it is listed. Please help Thans & Regards Uma (3 Replies)
Discussion started by: umapearl
3 Replies

5. Shell Programming and Scripting

Problem with script generating files in directory recursively

I have a script which generates recursively some files in folders for a given root folder. I have checks for permissions and it works for all folders except one(i have 777 permission on it). When i try calling the script in problematic folder(problematic folder being root folder), script works as... (2 Replies)
Discussion started by: bb2
2 Replies

6. UNIX for Dummies Questions & Answers

Copy files recursively

Hello! I know what i s recursion, but can't imagine what shoudl be "recursicve copying" of files? Please, what should mean: cp -r /home/hope/files/* /home/hope/backup Can someone helpme with a simple example? Many thanks!!! (6 Replies)
Discussion started by: pinklemon
6 Replies

7. UNIX for Dummies Questions & Answers

Find most recent file and copy to another directory.

Very new to shell scripting. Not sure if my title is correct but I will try and explain. Directory has 100+ files with this format, " ABCD_ABC_Abc_AB0126.abc ". When a new file gets created, the 16-19 characters in the file name gets incremented by 1. Ex...todays most recent file is... (14 Replies)
Discussion started by: askvip
14 Replies

8. Shell Programming and Scripting

How to rename (move) most recent files in directory?

I'm using cygwin32 on Windows. DN is an environment variable pointed at my download directory. This command works to move the single most recent file in my download directory to my current directory: mv "`perl -e '$p = $ARGV; opendir $h, $p or die "cannot opendir $p: $!"; @f = sort { -M $a... (2 Replies)
Discussion started by: siegfried
2 Replies

9. Shell Programming and Scripting

Copy Specific Files Recursively

Is it possible to only copy selected files+its directories when you are copying recursively? find /OriginalFolder/* -type -d \{ -mtime 1 -o -mtime 2 \ } -exec cp -R {} /CopyTo/'hostname'__CopyTo/ \; -print From the above line, I want to only copy *txt and *ini files from /OriginalFolder/* ... (4 Replies)
Discussion started by: apacheLinux
4 Replies

10. Shell Programming and Scripting

Copy files recursively to one single directory

I need to copy a complete directory structure into a new location. But I want to have all files copied into one directory and leave out the directory structure. So all files must be placed in one directory. (4 Replies)
Discussion started by: ReneVL
4 Replies
CPMAC(1)						    BSD General Commands Manual 						  CPMAC(1)

NAME
/usr/bin/CpMac -- copy files preserving metadata and forks SYNOPSIS
/usr/bin/CpMac [-rp] [-mac] source target /usr/bin/CpMac [-rp] [-mac] source ... directory DESCRIPTION
In its first form, the /usr/bin/CpMac utility copies the contents of the file named by the source operand to the destination path named by the target operand. This form is assumed when the last operand does not name an already existing directory. In its second form, /usr/bin/CpMac copies each file named by a source operand to a destination directory named by the directory operand. The destination path for each operand is the pathname produced by the concatenation of the last operand, a slash, and the final pathname compo- nent of the named file. The following options are available: -r If source designates a directory, /usr/bin/CpMac copies the directory and the entire subtree connected at that point. This option also causes symbolic links to be copied, rather than indirected through, and for /usr/bin/CpMac to create special files rather than copying them as normal files. Created directories have the same mode as the corresponding source directory, unmodified by the process' umask. -p Causes /usr/bin/CpMac to preserve in the copy as many of the modification time, access time, file flags, file mode, user ID, and group ID as allowed by permissions. -mac Allows use of HFS-style paths for both source and target. Path elements must be separated by colons, and the path must begin with a volume name or a colon (to designate current directory). NOTES
The /usr/bin/CpMac command does not support the same options as the POSIX cp command, and is much less flexible in its operands. It cannot be used as a direct substitute for cp in scripts. As of Mac OS X 10.4, the cp command preserves metadata and resource forks of files on Extended HFS volumes, so it can be used in place of CpMac. The /usr/bin/CpMac command will be deprecated in future versions of Mac OS X. SEE ALSO
cp(1) MvMac(1) Mac OS X April 12, 2004 Mac OS X
All times are GMT -4. The time now is 07:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy