04-15-2016
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 structure is preserved?
Can someone give me a sample /usr/bin/find command (or some other utility) that will only recreate those parts of the directory tree on a different memory stick that are younger than 3 hours?
Thank you
Siegfried
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT NETBSD
mount_union
MOUNT_UNION(8) BSD System Manager's Manual MOUNT_UNION(8)
NAME
mount_union -- mount union filesystems
SYNOPSIS
mount_union [-b] [-o options] directory uniondir
DESCRIPTION
The mount_union command attaches directory above uniondir in such a way that the contents of both directory trees remain visible. By
default, directory becomes the upper layer and uniondir becomes the lower layer.
Both directory and uniondir are converted to absolute paths before use.
The options are as follows:
-b Invert the default position, so that directory becomes the lower layer and uniondir becomes the upper layer. However, uniondir
remains the mount point.
-o Options are specified with a -o flag followed by a comma separated string of options. See the mount(8) man page for possible options
and their meanings.
Filenames are looked up in the upper layer and then in the lower layer. If a directory is found in the lower layer, and there is no entry in
the upper layer, then a shadow directory will be created in the upper layer. It will be owned by the user who originally did the union
mount, with mode "rwxrwxrwx" (0777) modified by the umask in effect at that time.
If a file exists in the upper layer then there is no way to access a file with the same name in the lower layer. If necessary, a combination
of loopback and union mounts can be made which will still allow the lower files to be accessed by a different pathname.
Except in the case of a directory, access to an object is granted via the normal filesystem access checks. For directories, the current user
must have access to both the upper and lower directories (should they both exist).
Requests to create or modify objects in uniondir are passed to the upper layer with the exception of a few special cases. An attempt to open
for writing a file which exists in the lower layer causes a copy of the entire file to be made to the upper layer, and then for the upper
layer copy to be opened. Similarly, an attempt to truncate a lower layer file to zero length causes an empty file to be created in the upper
layer. Any other operation which would ultimately require modification to the lower layer fails with EROFS.
The union filesystem manipulates the namespace, rather than individual filesystems. The union operation applies recursively down the direc-
tory tree now rooted at uniondir. Thus any filesystems which are mounted under uniondir will take part in the union operation. This differs
from the union option to mount(8) which only applies the union operation to the mount point itself, and then only for lookups.
EXAMPLES
The commands
mount -t cd9660 -o ro /dev/cd0a /usr/src
mount -t union /var/obj /usr/src
mount the CD-ROM drive /dev/cd0a on /usr/src and then attaches /var/obj on top. For most purposes the effect of this is to make the source
tree appear writable even though it is stored on a CD-ROM.
The command
mount -t union -o -b /sys $HOME/sys
attaches the system source tree below the sys directory in the user's home directory. This allows individual users to make private changes
to the source, and build new kernels, without those changes becoming visible to other users. Note that the files in the lower layer remain
accessible via /sys.
SEE ALSO
intro(2), mount(2), unmount(2), fstab(5), fsck_ffs(8), mount(8), mount_null(8), sysctl(8)
HISTORY
The mount_union command first appeared in 4.4BSD.
BUGS
Without whiteout support from the filesystem backing the upper layer, there is no way that delete and rename operations on lower layer
objects can be done. An attempt to mount a union directory under one which does not have whiteout support will return EOPNOTSUPP ("Operation
not supported"). Whiteout support can be added to an existing FFS filesystem by using the -c option of fsck_ffs(8).
Running find(1) over a union tree has the side-effect of creating a tree of shadow directories in the upper layer.
BSD
February 5, 2008 BSD