General :: Overwriting Specific Files In Directory Tree Recursively

Jul 19, 2011

I would like to overwrite files in a directory tree, recursively. The ones I would like to overwrite match the filename "x_alpha*.png" and have a size exactly 456 bytes. Is there any way to search for these recursively in a directory tree, and overwrite them with a reference file, for example "e:mydirgood.png"

I am using Windows 7, but I have UnxUtils, so I can use those too. What I am looking for is something like this, generated automatically:
copy /y e:mydirgood.png e:mydiracx_alpha0023.png
copy /y e:mydirgood.png e:mydirefgx_alpha0045.png
copy /y e:mydirgood.png e:mydirhx_alpha0248.png

View 2 Replies


Programming :: Sort Oldest 5 Files In A Directory Tree Recursively Based On Timestamp?

Jun 3, 2010

I have a directory listing with many subdirectories having many files. I want to recursively search for the oldest 5 files starting from the base directory and not 5 from each subdirectory. I am writing a shell script which sorts them using ls -lRtur|egrep "txt|jpg" > /tmp/file1 Now from this /tmp/file1 file I want to sort the files same as what the ls -ltr command does that is oldest file time to newest file time first. How do I sort based on Linux time stamp? The files itself also have Linux timestamps embedded in them So I can sort based after extracting them as well if it is easier.
My /tmp/file1 has entries like below.

-rw-rw-r--. 1 usr1 usr1 705 2010-01-22 17:25 sample20100603173659.jpg

I want to get the 5 oldest files and then delete them.

View 1 Replies View Related

General :: Command For Listing Files/dirs Recursively Of Specific Directories?

Jul 22, 2011

suppose in my current directory, I have 50 sub-directories. Now, I am interested only in about 20 of those sub-directories (whose names match a pattern). I would like to recursively list the contents of these 20 sub-directories. How do I do that ? I would like to do this in Solaris 10 and Linux(RHEL 5.x).

View 3 Replies View Related

General :: Recursively Count All The Files In A Directory?

Oct 12, 2010

I have a really deep directory tree on my Linux box. I would like to count all of the files in that path, including all of the subdirectories.

For instance, given this directory tree:


If I pass in /home, I would like for it to return 4 files. Or, bonus points if it returns 4 files, 2 directories. Basically, I want the equivalent of right-clicking a folder on Windows and selecting properties and seeing how many files/folders are contained in that folder.

How can I most easily do this? I have a solution involving a Python script I wrote, but why isn't this as easy as running ls | wc or similar?

View 5 Replies View Related

General :: Recursively Add Read Privilege To All The Files Under A Certain Directory?

Jan 18, 2010

I'm under linux . by default, other user can't read anything under my home directory. let's see my home directory is /home/superman , and I tried to use

chmod +r /home/superman

to let others can acess files under my home directory , but it does not work .

View 1 Replies View Related

General :: Recursively Remove Subdirectories And Files But Not The First Parent Directory?

Feb 11, 2010

I'm able to use the following to remove the target directory and recursively all of its subdirectories and contents. find '/target/directory/' -type d -name '*' -print0 | xargs -0 rm -rf

However, I do not want the target directory to be removed. How can I remove just the files in the target, the subdirectories, and their contents?

View 4 Replies View Related

General :: Rsync Files Recursively But Place In One Remote Directory?

Jan 29, 2011

i would like to find and backup all *.mp4 files from /Pictures and its sub-directories and move them to a single directory on a remote. I can find and move the files but I don't want the directory structure...just the files to be placed in the remote directory.

To find my files I use

rsync -r -a -v -e "ssh -l user" --delete --include '*/' --include '*.mp4' --exclude '*' /home/drew/Pictures/ remoteserver:/Users/drew/mp4

but this creates all the subdirectories

I also tried

find ~/Pictures -name "*.mp4" -exec rsync -r -a -v -e "ssh -l user" --delete {} remote:/Users/drew/mp4 ;

This works but takes forever

View 3 Replies View Related

Security :: Site Hacked - Deleting Specific Line From Files Recursively?

Apr 26, 2011

I just got an email from google saying my site contained malware. It has a line in it: "<script src=''></script>". I've noticed its recursively in all my .html and .txt files in my website. Can I make a linux script to run that will go through all my .html and txt files recursively and delete that line from them? I don't know how it got in all of them.

View 6 Replies View Related

Ubuntu :: Convert Files, But Keep The Directory Tree?

Jun 10, 2010

I've got a directory structure full of files. I want to convert them all into some other format, but I don't know how to keep the directory structure, is there a way so I can "set" which command to use on files instead of `cp`?

View 4 Replies View Related

Red Hat / Fedora :: Extracting Files In Sub Directory Recursively

Feb 27, 2010

I am new in Linux and I need to extract alot of zipped files (different format (e.g tar.gz, tar.gz2)) which are in subdirs and I do not want to go to each subdir and extract each file because it will take alot of time. Is there away to extract all files that are existing in dirs and subdir with "for loop" or is there a script that can do the job automatically.

View 1 Replies View Related

General :: Xargs And Unzip All Files To Specific Directory?

Jun 22, 2009

I'm trying to find all zip files timestamped from the past 7 days, then unzip them into a different director.I tried the following, but it only unzipped one of three files that meet the 7 day criteria. What am I missing?Code:find /home/user/public_html/zip_files/ -iname "*.zip" -mtime -7 -print0 | xargs -n10 unzip -LL -o -d /home/user/public_html/another_directory/

View 1 Replies View Related

Fedora :: Configure Grep To Search Recursively Through All Files In A Directory?

Oct 1, 2010

somewhere lurking is a file containing the default print resolution, which is not being overwritten by printer settings or cups management. I've asked on the cup forum and nothing successful.

So here's the question:

How can I configure grep to search recursively through all files in a directory, or if need be starting from root to find the pattern "2880" I've looked in the man page for grep and I can't see how to do it, is grep the right tool to use for this ?

View 2 Replies View Related

General :: Forbid Removal Of Files But Allow Creation Of Them For Specific Directory?

Jun 14, 2010

I have an application that creates temp files and quickly deletes them. But I'd like to keep those files, is there a way to do that in Linux?

View 2 Replies View Related

General :: Find Files With Specific Extension And Move To A Directory?

Apr 18, 2011

I need little help. I want to find all files with extension "*.tar" "*.gz" and "*.zip" and move all those files into "/opt/old" directory. I've tried this command:


find . -type f -name "*.tar" "*.gz" "*.zip" -print0 | xargs -0 -r mv /opt/test

It's not working, something wrong after "mv" i guess.

View 10 Replies View Related

General :: Searching A Specific Directory For Files Containing A Text String?

Nov 20, 2010

I am a member of a group which has written a program whose source code is being held in a specific directory (~cs252/Assignments/basicAsst/project) and we want to go through and change the parameters for the function "sequentialInsert." My job is to find all occurances of the function call to "sequentialInsert" and to also list the files from where the code came from. Also, I have to be in the commandsAsst directory when I do this. I have tried grep and find combined together, and I am at a lost.

View 1 Replies View Related

General :: Recursively Find A .doc File That Contains A Specific Word?

Aug 31, 2011

I'm using bash under Ubuntu.Currently this works well for the current directory:catdoc *.doc | grep "specificword" But I have lots of subdirectories with .doc files.How can I search for, let's say, "specificword" recursively?

View 2 Replies View Related

General :: Making Specific Script Loop Over Multiple Files In Directory?

May 10, 2011

I am trying - to no avail - to take an old script I found in the forum help-needed-in-grep-for-tar-gz-658730/ The code:

if zgrep $1 $2 > /dev/null 2>&1


View 3 Replies View Related

General :: Create Archives Of A Directory Tree On Ubuntu Box?

Oct 29, 2010

Are there any other archiving tools than tar that preserve Linux file permissions and user/group flags? I want to create archives of a directory tree on my ubuntu box. The directory trees are large, a first run with tar cvpzf archive.tgz /home/foo/bar yielded a 5GB archive. I also want to keep all permissions and other flags and special files.I'm fine with a 5GB archive, however to look inside that archive -- since it is a compressed tar archive -- the whole 5GB have to be decompressed first! (Or so it appears when opening it with the archive viewer -- I'm happy to be corrected.)So I need a way to "backup" a directory (tree) while preserving full filesystem attributes and right and creating an archive with an "index" that hasn't to be decompressed for browsing its contents. An archive is either a single file, or a (small) set of files that carries full and complete information within this file/s. That is, it can live on any filesystem (size permitting), it can be burnt onto a DVD, you can split it (after which the point of this question is really lost - but still), ...

View 3 Replies View Related

General :: Rsync To Copy Directory Tree From NAS Drive ?

Apr 10, 2010

I have a WD world book edition 1TB NAS drive, and just purchased an acomdata 1tb drive and connected it to the NAS via USB. If I recall I think the WD NAS has a ext_ or some type of linux filesystem on it, and the acomdata has a ntfs filesystem on it.

What I want to do is copy over certain directory trees of the NAS to the USB attached drive. I usually use MS synctoy to sync folders from my windows pc to the NAS drive, and MS richcopy to make the initial transfer from PC to NAS. For this operation though, since it is taking place entirely on the NAS and its connected drive, I thought that rsync would be the best option, and it is available on my NAS drive.

Last night I entered in rsync -avr /movies/* /usb1-1share1/ to copy the entire "movies" dir to the drive, which shows up as usb1-1share1 on the NAS drive. It copied most of the directory tree ok, but a lot of the folders were empty, so this morning I tried rsync -Carv --ignore-existing /movies/* /usb1-1share1/ to try and get all the files missed, without recopying the 24GB that did make it across. This also managed to copy a few more GB over, but not everything.

I am running the command from an ssh session on the NAS using putty on my PC, in as user "admin" which should have all rights over these folders. There is a bunch of errors in the command window like this: rsync: failed to set times on "/shares/usb1-1share1/movies/classics/fulldvd/First Blood DVD/.VTS_01_2.VOB.RxdjWZ": Operation not permitted (1)

I want to restart another session and get the files it missed, but I want to find out what I am doing wrong first. Should I be doing this as root user? am I missing some switches or just plain doing it all wrong?

View 3 Replies View Related

General :: Ftp Whole Directory Tree Using Vsftpd As Ftp Server In Fedora11

Feb 11, 2010

I am trying to ftp a whole directory tree using vsftpd as ftp server in fedora11


I am getting error while transfering a directory tree ...

View 1 Replies View Related

General :: Cannot Predict How Many Levels Deep Directory Tree Is

Sep 30, 2010

This little fragment does the opposite of what I want and I am trying to figure out how to reverse it. I want to strip off the directory and echo just the filenames. I cannot predict how many levels deep the directory tree is.

View 6 Replies View Related

General :: How To Recursively Copy Directory Into Another One

Apr 25, 2011

I moved to Mac OS X recently and bumped into the "feature" of Mac where copying files from an external drive resets the file modification/update date/timestamp to the current date (which Windows does not), causing a disaster for my 10+ years of backup work files where date is important. So, before I learned how to avoid that (e.g. using the -p "preserve" flag in the "cp" copy command) I have in the meantime added to my new Mac hard drive many more files as well as updating existing old files.

I have a backup external hard drive with all my old data and proper modification dates. I have a Mac hard drive with reset modification file dates (a single or two particular days). The Mac hard drive has all the "true" and "current" file contents with files modified and added. I need to Copy all the original files from the external harddrive, preserving file metadata (really only modified date), but ONLY overriding the new internal Mac hard drive IF

The file contents (md5 or whatever) is the same or The file was updated after the day (which of course I can see on all files) on which the original disasterous cope was performed (implying the file is new or modified) Ensure the copy leaves all the new and modified files completely intact on the Mac internal hard drive. "No prompting/stopping of the copy of any kind (i.e., not verbose) is required but is o.k". "Recursive copy - obviously I would like to copy all* files folders and subfolders found in export".

View 1 Replies View Related

General :: Recursively Download An Entire Web Directory?

Feb 3, 2010

i have a web directory that has many folders and many sub folders containing files.

i need to download everything using wget or bash.

View 7 Replies View Related

General :: Copy Permissions From One Directory Recursively To Another?

May 23, 2011

I have a system where the permissions of many files are messed up. I have another system that has the same files, if I put that hard drive in, without simply overwriting the files, is there a way where I can recursively set the permissions of each file to that of this other directory?

View 1 Replies View Related

General :: Get The Last Change Time Of Directory Recursively

May 28, 2011

How can I get the last time any of the files in a directory or its subdirectories has changed?

Dir - changed 1/1/1
Sub Dir 1 - changed 2/1/1
Sub Dir 2 - changed 3/1/1
File 1 - changed 10/1/1
File 2 - change 5/1/1

The output for this for Dir should be 10/1/1 (File 1 was the last modified one). Getting the last file name to be modified is a bonus but isn't necessary.

View 3 Replies View Related

General :: Search LDAP Directory Recursively?

Oct 12, 2010

How would the command for recursive search in LDAP look like when I'm searching for "cn" or "ou"?

View 3 Replies View Related

General :: Zip -x For A Directory - Subfolder Contents Not Being Excluded Recursively?

Dec 9, 2010

I am attempting to use the zip command with the '-x' option to exclude a folder e.g. 'zip public_html -x public_html/jquery/*'. However, parts of this folder are still being added to the archive. I made a shell script (saved as '' and ran as '.') to do the archiving so I could test adding nested wildards for multiple subfolder levels.


rm -f
zip -r public_html
-x public_html/jquery


Each new line I added here that has the nested wildcards made the archive file size a bit smaller. Adding more /*'s than this didn't affect the file size. Even after all this though, there were still a couple megabytes of files and folders from the 'jquery' directory that were added to the archive.

Here's some examples of files and folders that were created after I unzipped the archive:
public_html/jquery/js/tablesorter/addons/pager/icons [folder]
public_html/jquery/js/tablesorter/addons/pager/.svn/entries [file]
public_html/jquery/js/tablesorter/build/.svn/text-base/js.jar.svn-base [file]

Why is it that despite all the -x lines, the files and folders like these were still being added to the archive? How can I simply recursively exclude the entire public_html/jquery folder from the archive?

View 4 Replies View Related

General :: Specific "nesting Tree" Should Be Using?

May 9, 2010

I am building my first Linux file server, for my home network. I'm also trying to use older spare components I already own, so I won't unduly stress a tight family budget.

First, the issue: I cannot create more than four partitions on a given drive. I believe I remember reading somewhere that drives are limited to four primary partitions, but that its possible to "nest" multiple extended partitions within a single, larger, primary partition.

What I have been unable to find so far is anything to tell me what, if any, protocol I have to follow to accomplish functional nesting. Is one partition-type or mount point better than another for the primary? Are certain mount points better or worse for use as the nested partitions? Is there a specific "nesting tree" I should be using?

Here's some specs on what I'm working with: I have a 64-bit mobo with AMD 4800+ x64 in an Antec full-tower case, with 750 W PSU. I used the mobo's built-in Nvidia RAID controller to create a mirror with matched pair of 300 GB SATA hdd. Two additional mirrors are created through an SLI-PCI-IDE card: one with a pair of 250GB IDE hdd and the other with pair of 80 GB IDE hdd. I also have a stand-alone 13.2 GB IDE that I plan to use as the /swap drive, regardless of any other partitioning decisions. Also have a 200 GB IDE, on mobo cntrllr # 2, Mstr, with no particular purpose right now. I originally attempted to use Ubuntu 9.10, but apparently it did not install a boot-loader, and I was unable to make any of the suggested GRUB-loader tools resolve that issue. So I am currently using SUSE 11.2. (If there's a better option for my needs,please shout it out. There's no better time to switch boats than while you're still docked!)


View 6 Replies View Related

General :: Copying Jpegs Recursively While Preserving The Directory Structure?

Aug 9, 2010

So I have a bunch of directories:


which themselves all contain subdirectories:

dir1subdir1subdir2etc.and at the lowest level they contain all of these jpegs that I need. The problem is that I only need some of them. They're named like this:


I want to just grab the ones without the size suffix and copy them all to another set of folders, while preserving the directory structure. The numbering all starts at 1 for each low level subdirectory, so I think that the directory structure is the only way to not get them mixed up.

I know that cp has a recursive option -r but how do I just extract the ones without the underscore? And then how do I preserve the directory structure when I move them over?

View 1 Replies View Related

General :: Recursively Cp All Directories, Files And Hidden Files?

May 17, 2010

Ubuntu 10.04

I want to copy all directories, files, and hidden files and hidden directories with one command. I want these items to replace any same items in the target directory.

I have tried several things, such as:

cp -r *
cp -aR *

but I only seem to get visible files and directories. Obviously, I am missing something. (A brain, probably....)

View 9 Replies View Related

Copyrights 2005-15, All rights reserved