Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-03-2004, 02:20 PM
|
#1
|
LQ Newbie
Registered: Aug 2004
Location: Duluth, MN
Distribution: Slackware, Debian, FreeBSD
Posts: 10
Rep:
|
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.
|
|
|
09-03-2004, 02:29 PM
|
#2
|
LQ Newbie
Registered: Aug 2004
Location: Duluth, MN
Distribution: Slackware, Debian, FreeBSD
Posts: 10
Original Poster
Rep:
|
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?
|
|
|
09-03-2004, 03:18 PM
|
#3
|
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:
|
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.
|
|
|
09-03-2004, 04:53 PM
|
#4
|
LQ Newbie
Registered: Aug 2004
Location: Duluth, MN
Distribution: Slackware, Debian, FreeBSD
Posts: 10
Original Poster
Rep:
|
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.
|
|
|
09-05-2004, 02:14 AM
|
#5
|
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:
|
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.
|
|
|
09-08-2004, 08:35 PM
|
#6
|
Member
Registered: Mar 2003
Location: Bellevue, WA
Distribution: Arch w/ XFCE
Posts: 834
Rep:
|
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.
|
|
|
09-09-2004, 01:05 AM
|
#7
|
Member
Registered: Aug 2004
Location: Italia + UK
Distribution: RHEL 4 + Fedora FC5
Posts: 118
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 10:08 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|