Sponsored Content
Top Forums Shell Programming and Scripting Problem with script generating files in directory recursively Post 302537479 by jim mcnamara on Friday 8th of July 2011 10:10:16 AM
Old 07-08-2011
If it is trying to overwrite an existing file owned by someone else it will fail. That is among the most likely causes for your problem.

Once a file exists in a 777 directory, actions are dictated by the permissions and ownership of the file.
 

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 older than 5 minutes in directory (recursively)

sorry guys can some please give me a hint how to achieve this in a slick oneliner? delete files older than 5 minutes in specified directory (recursively) peace (3 Replies)
Discussion started by: scarfake
3 Replies

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

4. Shell Programming and Scripting

Generating an xml having information related to files in the directory

Hi all, Have to generate an xml having information related to files in the directory Suppose i have file file1.xml (datafile) file2.xml (datafile) file3.xml (metafile) Now i need to generate an xml in the format >> <?xml version="1.0" encoding="UTF-8"?> <AuditFile Version="2.0">... (8 Replies)
Discussion started by: abhinav192
8 Replies

5. Solaris

Display the number of files in a directory and recursively in each subdirectory

Display the number of files in a directory and recursively in each subdirectory To look something like below, for example /var 35 /var/tmp 56 /var/adm 46 Any ideas how can we do this? :wall: (1 Reply)
Discussion started by: jakerock
1 Replies

6. Solaris

Display the number of files in a directory and recursively in each subdirectory

Display the number of files in a directory and recursively in each subdirectory To look something like below, for example /var 35 /var/tmp 56 /var/adm 46Any ideas how can we do this? Got a sun cluser global mount point which takes ages to mount everytime, need to understand... (5 Replies)
Discussion started by: jakerock
5 Replies

7. Shell Programming and Scripting

Recursively cat files in a directory with filename printed first.

I want to recursively cat the content of files in a directory e.g. find /etc -type f -exec cat {} \; But I want it to print the file name first and then the content. For example let's say /etc/statetab and /etc/colord.conf will be printed first then I want the output to look something like; ... (6 Replies)
Discussion started by: lewk
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
CP(1)							    BSD General Commands Manual 						     CP(1)

NAME
cp -- copy files SYNOPSIS
cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] source_file target_file cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] source_file ... target_directory DESCRIPTION
In the first synopsis form, the cp utility copies the contents of the source_file to the target_file. In the second synopsis form, the con- tents of each named source_file is copied to the destination target_directory. The names of the files themselves are not changed. If cp detects an attempt to copy a file to itself, the copy will fail. The following options are available: -H If the -R option is specified, symbolic links on the command line are followed. (Symbolic links encountered in the tree traversal are not followed.) -L If the -R option is specified, all symbolic links are followed. -P If the -R option is specified, no symbolic links are followed. This is the default. -R If source_file designates a directory, cp 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 cp 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. Note that cp copies hard linked files as separate files. If you need to preserve hard links, consider using tar(1), cpio(1), or pax(1) instead. -f For each existing destination pathname, remove it and create a new file, without prompting for confirmation regardless of its permis- sions. (The -f option overrides any previous -i or -n options.) -i Cause cp to write a prompt to the standard error output before copying a file that would overwrite an existing file. If the response from the standard input begins with the character 'y' or 'Y', the file copy is attempted. (The -i option overrides any previous -f or -n options.) -n Do not overwrite an existing file. (The -n option overrides any previous -f or -i options.) -p Cause cp 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. If the user ID and group ID cannot be preserved, no error message is displayed and the exit value is not altered. If the source file has its set user ID bit on and the user ID cannot be preserved, the set user ID bit is not preserved in the copy's permissions. If the source file has its set group ID bit on and the group ID cannot be preserved, the set group ID bit is not pre- served in the copy's permissions. If the source file has both its set user ID and set group ID bits on, and either the user ID or group ID cannot be preserved, neither the set user ID nor set group ID bits are preserved in the copy's permissions. -v Cause cp to be verbose, showing files as they are copied. For each destination file that already exists, its contents are overwritten if permissions allow. Its mode, user ID, and group ID are unchanged unless the -p option was specified. In the second synopsis form, target_directory must exist unless there is only one named source_file which is a directory and the -R flag is specified. If the destination file does not exist, the mode of the source file is used as modified by the file mode creation mask (umask, see csh(1)). If the source file has its set user ID bit on, that bit is removed unless both the source file and the destination file are owned by the same user. If the source file has its set group ID bit on, that bit is removed unless both the source file and the destination file are in the same group and the user is a member of that group. If both the set user ID and set group ID bits are set, all of the above conditions must be fulfilled or both bits are removed. Appropriate permissions are required for file creation or overwriting. Symbolic links are always followed unless the -R flag is set, in which case symbolic links are not followed, by default. The -H or -L flags (in conjunction with the -R flag) cause symbolic links to be followed as described above. The -H, -L and -P options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are determined by the last one specified. DIAGNOSTICS
The cp utility exits 0 on success, and >0 if an error occurs. COMPATIBILITY
Historic versions of the cp utility had a -r option. This implementation supports that option, however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links or fifo's. The -v and -n options are non-standard and their use in scripts is not recommended. SEE ALSO
mv(1), rcp(1), umask(2), fts(3), symlink(7) STANDARDS
The cp command is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. HISTORY
A cp command appeared in Version 1 AT&T UNIX. BSD
July 23, 2002 BSD
All times are GMT -4. The time now is 11:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy