General :: How To Use Find To Copy All Found Files To A New Name In Their Same Directories

Feb 23, 2010

I've got a simple command that does almost what I want.

The following will locate all files with a suffix of '_compressed.swf' and copy each into its same directory with a '.bak2' appended:

However, I need to replace '_compressed.swf' with '_content.swf' I'd like to use find, rather than recursive flag on cp for consistency.

Objective
In: /content/somefile_compressed.swf
Out: /content/somefile_content.swf

View 3 Replies


ADVERTISEMENT

General :: Script To Find New Files And Copy Them Into Different Directories?

Oct 29, 2010

I have a question which has been in part answered many times but nothing I found relateds completely to my situation. I am sure there will be people who will say RTFM but believe me I did, and searched as well but to no avail. I have a situation where I want to copy files created withing last hour in one directory into another one. The problem is that that the directories are on different levels in the dir tree so the absolute path is different. But I want to keep the relative path the same.

I want to copy new files from /mnt/path_to_webdav/user to /home/user. so if there is new file /mnt/path_to_webdav/user/doc/xy.txt I want it to be copied to /home/user/doc/xy.txt. Also if there is a new dir, say /mnt/path_to_webdav/user/newdir I want a new dir to be created in /home/user/newdir with all the files in it, should there be any. I can do find with exec and copy all the files into one directory.This is not what I want though. How do I preserve the relative path and get the files copied into their corresponding directories?

View 1 Replies View Related

General :: Creating A Script To Move Or Copy Files Into Multiple Directories Below The Files?

Aug 25, 2009

How can you create a script to move or copy files from a main directory into multiple directories below the main directory.

View 7 Replies View Related

General :: Copy Wildcard Files From Directories For Matching

Feb 11, 2011

I have 2 massive duplicate dirs of the same format as below:
dir1
subdir1
file1
subdir2
file1
subdir3
file1
...

Dir2 is the same, but it has some newer files of the same name. I want to copy all file1's from Dir2 to the same name and folders in dir1. So basically something like:
cp -pr bkpDir1/*/*-big.gif Dir2/*/*-big.gif

This works for singular cases:
cp -pr bkpDir1/uniquesubdir/*-big.gif Dir2/uniquesubdir/*-big.gif

But not for wildcards:
cp -pr bkpDir1/subdir*/*-big.gif Dir2/subdir*/*-big.gif

Anyway the aim is to do the first cp above, I have tried a few options using find. In trying to show an example stumbled upon a way that worked, while in dir2:
find */*-big.gif | xargs -i cp -rp {} ../dir1/{}
Sure there are better ways also...

View 1 Replies View Related

General :: Make All Files Non-executable Recursively Using Find Without Affecting Directories?

Sep 26, 2010

I need to strip the executable flag from all files within a certain directory and sub directories. Right now I'm doing it with a 2 step process

find /dir/ -type f -exec chmod ugo-x {} ;
find /dir/ -type d -exec chmod ugo+rx {} ;

Is it possible to modify the first line so that I can strip exec flag from all non-directory files? Since this needs to be done on a fairly regular basis across a lot of directories and files, I'd prefer not to use a bash script which would slow it down.

View 1 Replies View Related

General :: Back Up Scrip - Find / Cp / Md5sum / Rm - Move All Files And Directories

Oct 22, 2010

I want to move all files and directories that are 1 month old out to back up into a separate folder. There will be a lot of files and I want to make sure it copies properly. The problem I'm having is integrating a MD5SUM into it to check integrity. MD5SUM is not recursive, so I figured it would work in a loop when it copies each individual file, I'll do a md5sum on each file and delete that md5 once its verified it copied ok.

[Code]...

I also need some sort of error handling to output all md5's that didnt pass the hash check.

View 3 Replies View Related

Programming :: Copy Files To Dynamic Directories?

Feb 14, 2011

I have been searching for a solution to the following problem:

When my distro of choice updates Firefox web browser, the directory name is '/usr/lib/firefox-<version>'.
The problem here is that the directory name is dynamic by nature and doesn't allow a simple static solution, e.g.
'cp -rf /usr/local/files/bookmarks.html /usr/lib/firefox/defaults/profile'.

The same quandary applies when adding extensions, changing prefs etc.
I have looked at the following commands:-
find, sed, xargs, grep, awk, fprint.
Unfortunately my grasp of syntax and programming is very simple at best.

View 2 Replies View Related

General :: Find Document Files And Copy Them To Another Directory?

Nov 7, 2010

This is a bit of a basic question but I'm trying to copy all .doc files I find in a directory and copy them to another directory.I know each command:

find -name '*.doc' .

and:

cp filename location

how can I combine the two commands?

View 3 Replies View Related

General :: Find Found Files That Don't Exist?

Dec 7, 2010

I was using the following command to search for tmp files older than 15 days for deletionI used "ls -l" first just in case

Code:
find somedirectory/ -type f -ctime +15 -exec ls -l {} ;
then i noticed that occasionally i get a "No such file or directory" error

When I looked at the directory, the file was not there.How does "find" find a file that doesn't exist?Is it possible that the file can be deleted right at the moment after a file is found and before the command executed?

View 3 Replies View Related

Ubuntu :: Installing Car Whisperer - Files And Directories Not Found

Mar 28, 2009

I am a pretty new user to linux, I am trying to run a program called car whisperer. The file can be downloaded here trifinite site - the home of the trifinite.group the readme says to install just type $make #make install but this does nothing and I am not sure how to install it. There is a file called makefile which I try to run in terminal but it just gives me all sorts of errors about not being able to find files and directories. I have seen it run and the person simply types ./carwhisperer to run the program but I also get no directory or file here as well (probably cause I have not installed). I was able to install some programs using sudo apt-get install (filename) but I haven't found this command to work for this program.

View 5 Replies View Related

General :: Find A File And Just List The Found Files?

Aug 7, 2009

I use find / -name myfile to search files. But it will print out a very long list such as follow:

Code:

...
find: /var/empty/sshd: Permission denied
find: /etc/audit: Permission denied
find: /etc/httpd/conf/ssl.crl: Permission denied
find: /etc/httpd/conf/ssl.crt: Permission denied

[code]....

View 4 Replies View Related

General :: Create A Backup Directory And 3 Directories Within That And Some Files Within The 3 Directories And Then Back Them Up Ot Restore Them?

Dec 19, 2009

i am in need of linux help. iam at college and i need this back/restore script to pass this final part of an assessment. i require a backup script that will not only backup but also restore files to the relevent directories. e.g. users are instructed to store all wordprocessor files in a directory named wp. so i am needing to create a backup directory and 3 directories within that and some files within the 3 directories and then back them up ot restore them. l know i should/have to do this myself by been trying to get/understand info for the last few days and came up with zero.

View 14 Replies View Related

Ubuntu Security :: Ran A Chkrootkit Scan And Found - Suspicious Files And Directories ?

Aug 1, 2010

I ran a chkrootkit scan and found this: The following suspicious files and directories were found: /usr/lib/pymodules/python2.6/.path /usr/lib/xulrunner-1.9.2.8/.autoreg /usr/lib/firefox 3.6.8/.autoreg /usr/lib/jvm/.java-6-openjdk.jinfo

How do I get rid of this suspicious file?

View 4 Replies View Related

Ubuntu :: Nautilus Action To Find Files In Directories

Aug 27, 2010

When I am in Nautilus, I want to be able to select a directory, then right click (or some other action) to do a file find on that directory. The gnome-search-tool would be a good candidate for this, if it could be an action in Nautilus. I know I can do a file find through other means, but Nautilus seems to be where I am when I want to search directories.

View 6 Replies View Related

Ubuntu :: Find Files With Directories And Sort By Mod Time?

Dec 4, 2010

what i wanted to do was find all the files with a specific name from a tree, sort them by modification time and have their directory appended to them so that i knew where they were (because they all have the same name). i tried a whole bunch of different things and finally did this:

Code:
find . -type f -name world.sav -exec ls -l '{}' ; > ~/dfsaves.txt; gawk '{$1=""; $2=""; $3=""; $4=""; $5=""; print}' ~/dfsaves.txt | sort -n > ~/dfsavessorted.txt

this did the trick pretty well, but as you can see it is far from elegant and i think i'm doing some things wrong and kludgy

first thing i tried was "ls -lRt | grep world.sav" which worked except i couldnt distinguish the files because there were no directories. that took a lot of looking till i accepted i couldnt make ls print directories as well and append them to the files somehow that their relationship would be clear. i tried piping ls to find, doing it in reverse, passing them from grep etc. etc. until i read some more stuff online that got me using gawk and sort. the questions:

1. is there some other, more elegant and simple way to do this kind of detection and sorting?

2. is there any way to use a pipe after using exec? the semicolon seems to prevent this entirely, forcing me to use an intermediate file as above. i could just remove it later, but i'd prefer a straight piping.

View 8 Replies View Related

General :: How To Store Files / Directories In Different Different Directories?

Mar 23, 2011

I am writing a script, in that my requirement is, if all the fill types stored in one directory from that we need to separate different different directories based on the file types.

for example in a directory(anish). 5 different types files
1- directory
2- .txt files
2- .sh files

like that and my requirement is the (1- directory is moved to one new directory(dir) which we are given in the script)and (2 .txt files are moved to another new directory(test) which we are given in the script)and ( 2 .sh files are moved to another new directory(bash) which we are given in the scrip)finally the directory anish should be empty..using bash script.how it is possible !!

View 7 Replies View Related

General :: Find A File In Directories Without Using Find Command?

Aug 3, 2010

am new to linux and trying to find a file in sub directories using find command as:find .-name *.jpg -type fBut I am unable to get the result as find command is not permitted by the server administrator.Is there any way to find files without using find command.

View 14 Replies View Related

Red Hat / Fedora :: Fedora Shell Scripting \ "Find In Curent Folder For Files, And It Copy First File He Find With Name Gived By User?

May 18, 2011

shell scripting in Fedora14I want a script"Find in curent folder for files, and it copy first file he find with name gived by user, if name already exist then echo error message and finish"command usage " bash scriptname copyASname"

smthing like Code: #!/bin/bash
for files in /home/user/*
do

[code]....

View 1 Replies View Related

General :: Find Files In Subdirectories And Copy Them To Another Directory With The Same Subdirectories?

Nov 18, 2010

This question is very similar to this one except that I want to maintain the file's original subdirectories.

For example if I had

/temp/a/a.txt
/temp/a/a.jpg
/temp/a/b.txt
/temp/b/c.txt
/temp/d/d.txt
/temp/d/d.jpg
/temp/d/e.txt
/temp/f.txt

[Code]...

View 2 Replies View Related

General :: Copy A Set Of Sub Folders From Their Multiple Parent Directories To A New Location

Nov 5, 2010

I am attempting to copy a set of sub folders from their multiple parent directories to a new location.

For example, I have three folders to copy:

I would like them to be copied to:

In actuality there are many folders besides folder1, folder2, folder3, and no numerical order exists. So, the folder named 'photos' would be copied to its parent folder's name in a new location. I would need this to occur for all folders in the '/home/user' directory.

View 6 Replies View Related

Debian :: Find And Copy Same Files To Single Directory?

Feb 17, 2011

I have a number of crash.log files scattered about my system and I would like to run a command to find all the crash.log files on the system and copy them to a single directory; each with a unique filename. For example, copy crash.log from ~/directory_1 , ~/directory_2 , ~/directory_3 and so on to ~/crash_logs/crash.log1 , ~/crash_logs/crash.log2 , ~/crash_logs/crash.log3 etc.

View 1 Replies View Related

General :: Excluding Directories With Find?

Jun 10, 2011

I am trying to exclude 2 directories with find and pass it into cpio. I have tried

Code:
find . -depth -path '.evolution' -prune -o -path '.gconf' -prune -o -print|cpio -aov > /media/caca/full$date
./.gconf/apps/evolution/memos/%gconf.xml
./.gconf/apps/evolution/memos

[Code]....

View 4 Replies View Related

Ubuntu :: Total Filesize Of All Files Found With The Find Command?

Dec 21, 2010

i'd like to know the total filesize of all files found with the find command, so

Code:
find -iname '*.mpg' | xargs -I {} du -sh {}
but this gives me the filesize of each file, since each line is passed to "du".

how can I pass the whole list through the pipe?

View 6 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

General :: How To Exclude Multiple Directories In Awk With Find?

May 20, 2010

I found a script on webmaster world that mostly does what I need it to, but have been making modifications to tailor it to my specific needs.I know that //..*/ tells awk to ignore hidden directories, how do I define more directories to ignore? (i.e. temp, var, etc)? I've tried playing with prune before the awk command with limited success...I know that there are many ways to do the same thing and keep running into brick walls.

View 11 Replies View Related

General :: Scripting To Find Difference Between 2 Directories

Dec 17, 2010

Write a script to list all the differences between two directories.

View 1 Replies View Related

General :: Command To Find A Specific Word In Directories And Subdirectories?

Jun 7, 2010

tell me the command used to find a specific word in directories and sub-directories in linux?

View 4 Replies View Related

General :: Merging Two Files From Two Different Directories?

May 14, 2011

I'm totally new to Linux and this website. I was wondering if anyone had or could help me create a shell script that would merge two files from two different directories and then have that new merged file in a third differnt directory.The merged file would need to eliminate duplicates and sort the contents.

View 6 Replies View Related

General :: Remove Directories That Only Contain .txt And .log Files?

Aug 8, 2010

I'd like to remove all directories of a certain depth that don't contain .txt or .log files -- is this possible? So far I have: find ~ -mindepth 3 -maxdepth 4 -type d -exec rm -r '{}' ; Is it possible to add in "only if the directory doesn't contain .txt and/or .log files"? Or do I have to start learning perl to do that?

For example:
dir 1:
hello.txt
runme.sh
dir 2:
runme.sh
oct12.log
[Code]....

View 13 Replies View Related

General :: What Kinds Of Files Are Stored In The Directories

Mar 12, 2010

3.State what kinds of files are stored in the following directories. Give any ONE file that can be found in these directories.

a. /etc/
b. /proc/
c. /sbin/

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved