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
mkdirp(3GEN)					     String Pattern-Matching Library Functions					      mkdirp(3GEN)

NAME
mkdirp, rmdirp - create or remove directories in a path SYNOPSIS
cc [ flag ... ] file ... -lgen [ library ... ] #include <libgen.h> int mkdirp(const char *path, mode_t mode); int rmdirp(char *dir, char *dir1); DESCRIPTION
The mkdirp() function creates all the missing directories in path with mode. See chmod(2) for the values of mode. The rmdirp() function removes directories in path dir. This removal begins at the end of the path and moves backward toward the root as far as possible. If an error occurs, the remaining path is stored in dir1. RETURN VALUES
If path already exists or if a needed directory cannot be created, mkdirp() returns -1 and sets errno to one of the error values listed for mkdir(2). It returns zero if all the directories are created. The rmdirp() function returns 0 if it is able to remove every directory in the path. It returns -2 if a ``.'' or ``..'' is in the path and -3 if an attempt is made to remove the current directory. Otherwise it returns -1. EXAMPLES
Example 1 Example of creating scratch directories. The following example creates scratch directories. /* create scratch directories */ if(mkdirp("/tmp/sub1/sub2/sub3", 0755) == -1) { fprintf(stderr, "cannot create directory"); exit(1); } chdir("/tmp/sub1/sub2/sub3"); . . . /* cleanup */ chdir("/tmp"); rmdirp("sub1/sub2/sub3"); ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
chmod(2), mkdir(2), rmdir(2), malloc(3C), attributes(5) NOTES
The mkdirp() function uses malloc(3C) to allocate temporary space for the string. SunOS 5.11 14 Oct 2003 mkdirp(3GEN)
All times are GMT -4. The time now is 02:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy