Sponsored Content
Top Forums Shell Programming and Scripting Copy Specific Files Recursively Post 303010811 by Don Cragun on Sunday 7th of January 2018 10:24:43 PM
Old 01-07-2018
The find primary -mtime 1 looks for file that were modified exactly 24 hours ago to the finest resolution of timestamps available on the filesystem you're traversing. If you want to look for files that were modified sometime up to 48 hours ago, you would do that with:
Code:
find ... -mtime -2

And, if you need to group primaries together in an expression, you need to surround them with escaped parentheses such as:
Code:
\( primary -o primary \)

not with braces such as:
Code:
\{ primary -o primary \}

and there can never be any space between the backslash character and the escaped parenthesis following it.

Maybe you want something more like:
Code:
find $(find /OriginalFolder -type -d -mtime -2) -depth \( -name '*.ini' -o -name '*.txt' \)

to get a list of absolute pathnames of the files you want to copy as long as the files you want to copy only appear in leaf directories. You'll have to do some post-processing of the output to recreate the directory hierarchy using something like cpio, pax, or tar to keep the original ownership and modes.

But, of course, this assumes that your list of directories updated in the last two days is not large enough to cause a command-line too long error as it constructs the outermost find command.

And, as RudiC noted, if a file in a directory is updated without creating a new file or deleting an old file, the directory timestamp won't be updated.

None of this has been tested, but hopefully it will give you a way to start moving forward. Note that if directories other than those that are leaves on the tree are updated, some of the files in the list produced might not actually be in a directory whose leaf directory changed in the last two days AND if non-leaf directories are updated some files may appear in the output list more than one time so you may need to weed out duplicates.
 

10 More Discussions You Might Find Interesting

1. Solaris

To copy the files newer than specific date

Dear all, Can you help me in copying files newer than speciifc date Thanks in advance, Rajesh (3 Replies)
Discussion started by: RAJESHKANNA
3 Replies

2. 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

3. 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

4. Shell Programming and Scripting

copy specific files and count them - not as easy as it seems!

Hi all: Here's my dilemma: to identify files of a specific type, copy them to a new location while preserving the original file attributes (date, time, full path, etc), and at the same time capture the count of the number of files identified as a variable for later reporting. Here's where I... (9 Replies)
Discussion started by: Yamaha Evans
9 Replies

5. Shell Programming and Scripting

Recursively move directories along with files/specific files

I would like to transfer all files ending with .log from /tmp and to /tmp/archive (using find ) The directory structure looks like :- /tmp a.log b.log c.log /abcd d.log e.log When I tried the following command , it movies all the log files... (8 Replies)
Discussion started by: frintocf
8 Replies

6. Shell Programming and Scripting

How to copy a directory without specific files?

Hi I need to copy a huge directory with thousands of files onto another directory but without *.WMV files (and without *.wmv - perhaps we need to use *.). Pls advise how can I do that. Thanks (17 Replies)
Discussion started by: reddyr
17 Replies

7. 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

8. Shell Programming and Scripting

How to recursively copy directory only for recent files?

I love the -newerct flag for the Cygwin find command on windows. Can I use "/usr/bin/find . -newerct '3 hours ago'" to conditionally copy a directory tree so that only the files in the directory tree that are younger than 3 hours are copied to my destination directory such that the directory... (4 Replies)
Discussion started by: siegfried
4 Replies

9. Shell Programming and Scripting

Find Large Files Recursively From Specific Directory

Hi. I found many scripts in the web of achieving this. But I like to use this one find /EDWH-DMT03 -xdev -size +10000 -exec ls -la {} \;|sort -n -k 5 > LARGE.rst But the problem is, why it still list out files with 89 bytes as the output? Is there anything wrong with the command? My... (7 Replies)
Discussion started by: aimy
7 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
cmcp(1m)																  cmcp(1m)

NAME
cmcp - Copy files between Serviceguard nodes SYNOPSIS
cmcp [-rv] [src_node:]src_file [...] [dest_node:]dest_file DESCRIPTION
cmcp copies files and/or directories between Serviceguard nodes. cmcp is limited in several ways. cmcp is best suited for situations where other remote copy facilities are not available. For a more full featured tool for copying files between Serviceguard nodes, see ccp(1m) provided by Distributed Systems Administration Utilities. To use this command, the local user must have the root access role on each of the involved nodes. For more information on Serviceguard access control policies, see the manual, Managing Serviceguard. Paths may be relative to the current working directory or specified absolutely. The current working directory on a remote node is assumed to be the same as the local node's directory. Copies between two remote hosts are permitted. If a file or directory already exists on the destination node, the destination node's copy will be overwritten with no prompting. The cmcp command is not suited for large files or large numbers of files and may result in a heavy load on the command and Serviceguard daemons. Other tools such as ccp should be considered for these purposes. Options And Arguments -r Recursively copy entire directories. -v Verbose output will be displayed. src_node Serviceguard node to retrieve the file from. Defaults to the local node. src_file Path to source file on src_node. dest_node Serviceguard node to copy file to. Defaults to the local node. dest_file Path to copy src_file to on the dest_node. RETURN VALUE
cmcp returns the following values: 0 Successful completion. 1 Command failed. EXAMPLES
Copy the local file /etc/hosts to remote node node1 cmcp /etc/hosts node1:/etc/hosts Copy the remote file /etc/passwd on node1 locally cmcp node1:/etc/passwd /tmp/passwd.poe Copy a local script directory to a remote node cmcp -r /etc/cmcluster/scripts node1:/etc/cmcluster AUTHOR
cmcp was developed by HP. SEE ALSO
rcp(1), scp(1), ccp(1m), cmsync(1m), cmexec(1m), cmdo(1m), cmquerycl(1m), cmviewcl(1m) Requires Optional Serviceguard Software cmcp(1m)
All times are GMT -4. The time now is 08:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy