LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 09-03-2004, 02:20 PM   #1
krazykow
LQ Newbie
 
Registered: Aug 2004
Location: Duluth, MN
Distribution: Slackware, Debian, FreeBSD
Posts: 10

Rep: Reputation: 0
copying multiple files..???


I've enountered this situation on multiple systems....

On a particular server there are image files strung about the webroot directory structure....example

/wwwroot/605/cf/fblahblah/images/OLD_fiserwringn616.jpg
/wwwroot/205/gnd/blahhdf/image1/dr3/ghhd/OLD_blhja43newone.gif
/wwwroot/sd/234/45554/sdfgsdfsg/whatever/whateverelse/in/more/directories/forever/OLD_2335435.jpg

all the image files are in the OLD_*.extension naming scheme. I'm needing to move ALL 600+ like this to one backup directory. I have considered several ways of doing this, but Im under HUGE time constraints. I was wondering if anyone had done this before and if they could offer advice or script concepts for it.

Please help me. I'm under a lot of pressure.
 
Old 09-03-2004, 02:29 PM   #2
krazykow
LQ Newbie
 
Registered: Aug 2004
Location: Duluth, MN
Distribution: Slackware, Debian, FreeBSD
Posts: 10

Original Poster
Rep: Reputation: 0
also....I tried a string similar to this.....maybe I'm close....

find /home/joe *.exe | grep *.exe | mv '{print1}' /home/joe/exe

this is an example.....

Im trying to take the output from find and mv line-by-line that content to /home/joe/exe....it errors out...but am I close in concept?
 
Old 09-03-2004, 03:18 PM   #3
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
If all the files aren't in the same sub directory, then you probably want to make use of xargs it will take the output of some command and use that as arguments to another command.

Something along the lines of:
find /path -name "OLD_*.jpg" | xargs -i % mv % /newpath/

Should be what you're after.
 
Old 09-03-2004, 04:53 PM   #4
krazykow
LQ Newbie
 
Registered: Aug 2004
Location: Duluth, MN
Distribution: Slackware, Debian, FreeBSD
Posts: 10

Original Poster
Rep: Reputation: 0
MY SOLUTIONS!!!

you pointed me in the right direction thank you so much!!!!

xargs....I must remember this.

For a linux system...this is the command string I passed:

find /home/joe -name "*.exe" | xargs -i mv {} exe/directoryforallexes/

For a Solaris system....this is the command string I passed:

find /wwwroot/allthestuff -name "*OLD_*.*" | xargs -I {} -t mv {} /wwwroot/oldstuffonly/

solaris has a slighty different way of requesting the output AND how you tell the shell what you're trying to do, but I figured it out in minutes instead of hours. THANKS AGAIN!!!!

Also. I was wondering what you study for BSD. I spend a great deal of time reading Oreilly publications but I'm really diving into BSD bigtime.
 
Old 09-05-2004, 02:14 AM   #5
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
The respective website, and the man pages. Seriously, unlike any other OS I've ever used (Windows, Solaris, Linux, etc) the documentation for each BSD is really good. The man pages usually give you working examples of how to use a command or utility. Also, there is a huge amount of documentation found on the website for each BSD (well, Free, Net, and Open any way) that is extremely helpful.

In my free time I read Absolute BSD and Absolute OpenBSD, both by Michael Lucas. They weren't literary master pieces, but they were pretty helpful. Building Secure Arcitectures with OpenBSD by [whoops, book not in front of me and I've forgotten] is also quite good.
 
Old 09-08-2004, 08:35 PM   #6
orange400
Member
 
Registered: Mar 2003
Location: Bellevue, WA
Distribution: Arch w/ XFCE
Posts: 834

Rep: Reputation: 30
An excellent book to look into for Unix-based command line terminology is QUE - Think Unix. I have it, and teaches you little tricks like this all over the book. Highly reccomended.
 
Old 09-09-2004, 01:05 AM   #7
stevie_velvet
Member
 
Registered: Aug 2004
Location: Italia + UK
Distribution: RHEL 4 + Fedora FC5
Posts: 118

Rep: Reputation: 15
xargs is a excellent utility must read up more on this

also the is a -exec option in find, such that....

find /<path> -name '<pattern>' -exec mv{} <new_path> \; -print
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH Shell script : copying a file to multiple folder zamri Programming 14 04-29-2008 10:27 AM
copying files(s) in c climbingmerlin Programming 7 10-27-2005 02:00 PM
burning and copying cds to multiple drives quercusalba Linux - Software 4 09-24-2005 11:46 PM
Copying a single file to multiple directories tgolly Linux - Newbie 3 04-26-2004 03:47 PM
Help I need help tarring multiple files in multiple directories VisionZ Linux - Newbie 28 03-25-2004 05:25 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 09:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration