Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 10-14-2006, 11:22 PM   #1
LQ Newbie
Registered: Oct 2006
Posts: 1

Rep: Reputation: 0
find command

I want to copy all files from the output of:

find /mnt/WINDOWS/Temporary?Internet?Files/ -name '*.gif'

to /root/pics

What is the best way to do this?
Old 10-14-2006, 11:41 PM   #2
Registered: Jun 2006
Distribution: Slackware 10.2, Debian Testing/Unstable, Ubuntu Breezy Badger, working on LFS
Posts: 228

Rep: Reputation: 30
I don't like find. This should work instead:
for i in /mnt/WINDOWS/Temporary?Internet?Files/*.gif; do cp $i /root/pics/$i
Old 10-14-2006, 11:47 PM   #3
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,905

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
First, since you want to write to root users folder, you will have to run the command as root.

Second, something like this might work:

cp -R `find /mnt/WINDOWS/Temporary\ Internet\ Files/ -name '*.gif'` /root/pics

Note the backticks before find and after '*.gif'. Also note the backslash space in the Temporary\ Internet\ Files. cp -R says make recursive copy (through any directory structure in Temporary Internet Files; \ space escapes the space in the directory name; the backticks result in the find command being executed. The results of find are copied to /root/pics.

Or something along those lines, at any rate.

But, I like FreeDoughnut's version better.

Last edited by bigrigdriver; 10-14-2006 at 11:50 PM.
Old 10-15-2006, 12:18 AM   #4
Senior Member
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Ubuntu, FreeBSD
Posts: 1,449

Rep: Reputation: 48
find /mnt/WINDOWS/Temporary?Internet?Files/ -name "*.gif" -exec cp \{\} /root/pics \;
I can't understand why anyone would dislike find nor why someone would complicate it beyond what it already is by wrapping commands around it needlessly.

Edit: Explanation, "-exec" will execute the following commands terminated by a ";" (which must be escaped from the shell). And {} is replaced with the name of each matching file, in turn. We escape these as well just to ensure that the shell doesn't complain.

Last edited by frob23; 10-15-2006 at 12:20 AM.


fedora 4

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 05:30 PM
`find' command cdnsupra Linux - Newbie 4 12-18-2005 11:13 AM
find command jch02140 Linux - Newbie 2 07-19-2005 12:21 AM
help with the find command clockworks Linux - Software 2 02-17-2004 04:24 PM
not find mt command imsajjadali Red Hat 2 02-07-2004 06:27 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:00 PM.

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