[opensuse] pipe the output of 'find' to 'cp'
Hello listers, I need to pipe the names and locations of files I find by: find /home/username/folder -type f -name "*.doc" to: cp *.doc /home/username/doclist/ The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can not be easily done by routine find and cp. I only want to copy (not move) the .doc (and subsequently .txt) files, I do not want to retain any directory structure in the output folder. I've tried these three commands (and lots of variations) after a LOT of googling. cp `find /home/radagus/Desktop -type f -name "*.doc"` /home/radagus/Desktop/current/doclist find /home/username/folder -type f -name "*.doc" -exec cp {} /home/username/doclist/; find /home/username/folder -name \*.doc | cut -d':' -f1 | xargs -I{} cp --parents -v {} /home/username/folder/doclist/ The last one found some of the files but retained a great deal of directory structure. Any suggestions of what I can read or how to get this to work would be appreciated. Gustav. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Wed, Oct 28, 2015 at 10:01 PM, Gustav Degreef
Hello listers,
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can not be easily done by routine find and cp.
find . | cpio -pmdu /target/dir -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/28/2015 07:05 PM, Andrei Borzenkov wrote:
On Wed, Oct 28, 2015 at 10:01 PM, Gustav Degreef
wrote: Hello listers,
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can notbu be easily done by routine find and cp.
find . | cpio -pmdu /target/dir
find /home/dir -type f -name "*.doc" | cpio -pmdu /home/target/ That is what I ran. It does not work. I got 1,800+ files BUT I also got 800+ subfolders which obstruct the end result. Thanks, but something is still missing in the command. Thanks. Gustav. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
28.10.2015 23:59, Gustav Degreef пишет:
On 10/28/2015 07:05 PM, Andrei Borzenkov wrote:
On Wed, Oct 28, 2015 at 10:01 PM, Gustav Degreef
wrote: Hello listers,
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can notbu be easily done by routine find and cp.
find . | cpio -pmdu /target/dir
find /home/dir -type f -name "*.doc" | cpio -pmdu /home/target/
That is what I ran. It does not work. I got 1,800+ files BUT I also got 800+ subfolders which obstruct the end result. Thanks, but something is still missing in the command. Thanks. Gustav.
So you want to copy everything in a single directory? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/29/2015 04:20 AM, Andrei Borzenkov wrote:
28.10.2015 23:59, Gustav Degreef пишет:
On 10/28/2015 07:05 PM, Andrei Borzenkov wrote:
On Wed, Oct 28, 2015 at 10:01 PM, Gustav Degreef
wrote: Hello listers,
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can notbu be easily done by routine find and cp.
find . | cpio -pmdu /target/dir
find /home/dir -type f -name "*.doc" | cpio -pmdu /home/target/
That is what I ran. It does not work. I got 1,800+ files BUT I also got 800+ subfolders which obstruct the end result. Thanks, but something is still missing in the command. Thanks. Gustav.
So you want to copy everything in a single directory? Yes, exactly.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Thu, Oct 29, 2015 at 11:23 AM, Gustav Degreef
On 10/29/2015 04:20 AM, Andrei Borzenkov wrote:
28.10.2015 23:59, Gustav Degreef пишет:
On 10/28/2015 07:05 PM, Andrei Borzenkov wrote:
On Wed, Oct 28, 2015 at 10:01 PM, Gustav Degreef
wrote: Hello listers,
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can notbu be easily done by routine find and cp.
find . | cpio -pmdu /target/dir
find /home/dir -type f -name "*.doc" | cpio -pmdu /home/target/
That is what I ran. It does not work. I got 1,800+ files BUT I also got 800+ subfolders which obstruct the end result. Thanks, but something is still missing in the command. Thanks. Gustav.
So you want to copy everything in a single directory? Yes, exactly.
find . -print0 | xargs --null cp -t /path/to/target/dir see other xargs options how to control max number of arguments and parallelism. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/29/2015 08:43 AM, Andrei Borzenkov wrote:
On Thu, Oct 29, 2015 at 11:23 AM, Gustav Degreef
wrote: On 10/29/2015 04:20 AM, Andrei Borzenkov wrote:
28.10.2015 23:59, Gustav Degreef ÿøшõт:
On 10/28/2015 07:05 PM, Andrei Borzenkov wrote:
On Wed, Oct 28, 2015 at 10:01 PM, Gustav Degreef
wrote: Hello listers,
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can notbu be easily done by routine find and cp.
find . | cpio -pmdu /target/dir find /home/dir -type f -name "*.doc" | cpio -pmdu /home/target/
That is what I ran. It does not work. I got 1,800+ files BUT I also got 800+ subfolders which obstruct the end result. Thanks, but something is still missing in the command. Thanks. Gustav.
So you want to copy everything in a single directory? Yes, exactly.
find . -print0 | xargs --null cp -t /path/to/target/dir
see other xargs options how to control max number of arguments and parallelism.
Worked very well. Got 900+ files in one directory. This will be a cache of documents that Dragon Naturally Speaking (win prog) to analyze and build a profile of specific words I use and my writing style. This a text-to-speech program. I can move the profile from home to work. The cache is from 25+ years of stored files and documents (with thousands of medical terms and proper names). Thanks a lot for the help, Gustav
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2015-10-28 20:01, Gustav Degreef wrote:
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can not be easily done by routine find and cp.
Yes, it can :-) 'mc' (midnight commander) does it. Browse to source directory in left panel, to destination on right hand panel. On the left panel, hit "Command", then "find". Enter the pattern, recursive, no content. Wait. When it finishes the list, hit "Panelize" (alt-l). Hit "*" on numeric keyboard. All files will be selected. Finally, hit "F5" (copy) to copy all selected items to the right hand panel. And wait. It it finds a problem (duplicate filename, for instance), it will stop and ask. I find it easier that concocting a line with find, xargs, etc. Which is of course doable as well :-) -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
On 10/28/2015 07:29 PM, Carlos E. R. wrote:
On 2015-10-28 20:01, Gustav Degreef wrote:
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can not be easily done by routine find and cp. Yes, it can :-)
'mc' (midnight commander) does it.
Browse to source directory in left panel, to destination on right hand panel.
On the left panel, hit "Command", then "find". Enter the pattern, recursive, no content.
Wait.
When it finishes the list, hit "Panelize" (alt-l). Hit "*" on numeric keyboard. All files will be selected. Finally, hit "F5" (copy) to copy all selected items to the right hand panel.
And wait.
It it finds a problem (duplicate filename, for instance), it will stop and ask.
I find it easier that concocting a line with find, xargs, etc. Which is of course doable as well :-)
I love mc, use it all the time. But I had no idea it was that sophisticated. VERY cool, I will have to try this. Gustav
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/28/2015 05:02 PM, Gustav Degreef wrote:
On 10/28/2015 07:29 PM, Carlos E. R. wrote:
On 2015-10-28 20:01, Gustav Degreef wrote:
The subdirectory /folder contains more than 28,000 files and more than 2,600 subfolders, so it can not be easily done by routine find and cp. Yes, it can :-)
'mc' (midnight commander) does it.
Browse to source directory in left panel, to destination on right hand panel.
On the left panel, hit "Command", then "find". Enter the pattern, recursive, no content.
Wait.
When it finishes the list, hit "Panelize" (alt-l). Hit "*" on numeric keyboard. All files will be selected. Finally, hit "F5" (copy) to copy all selected items to the right hand panel.
And wait.
It it finds a problem (duplicate filename, for instance), it will stop and ask.
I find it easier that concocting a line with find, xargs, etc. Which is of course doable as well :-) I love mc, use it all the time. But I had no idea it was that sophisticated. VERY cool, I will have to try this. Gustav
exec ??? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2015-10-28 22:02, Gustav Degreef wrote:
On 10/28/2015 07:29 PM, Carlos E. R. wrote:
I love mc, use it all the time. But I had no idea it was that sophisticated. VERY cool, I will have to try this. Gustav
I did a bunch of copies yesterday this exact way, so I know it works ;-) -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
On 10/28/2015 08:01 PM, Gustav Degreef wrote:
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/
cp --help | grep -- --target -t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY Therefore, the command boils down to: find /home/username/folder -type f -name "*.doc" \ | xargs cp -t /home/username/doclist/ or (for unlucky file names with blanks etc.) find /home/username/folder -type f -name "*.doc" -print0 \ | xargs -0 cp -t /home/username/doclist/ or even find /home/username/folder -type f -name "*.doc" \ -exec cp -t /home/username/doclist/ '{}' + Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/28/2015 03:39 PM, Bernhard Voelker wrote:
On 10/28/2015 08:01 PM, Gustav Degreef wrote:
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/ cp --help | grep -- --target -t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY
Therefore, the command boils down to:
find /home/username/folder -type f -name "*.doc" \ | xargs cp -t /home/username/doclist/
or (for unlucky file names with blanks etc.)
find /home/username/folder -type f -name "*.doc" -print0 \ | xargs -0 cp -t /home/username/doclist/
or even
find /home/username/folder -type f -name "*.doc" \ -exec cp -t /home/username/doclist/ '{}' +
Have a nice day, Berny
also you need the root path? -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/28/2015 08:39 PM, Bernhard Voelker wrote:
On 10/28/2015 08:01 PM, Gustav Degreef wrote:
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/ cp --help | grep -- --target -t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY
Therefore, the command boils down to:
find /home/username/folder -type f -name "*.doc" \ | xargs cp -t /home/username/doclist/
or (for unlucky file names with blanks etc.)
Does not work. Result is: find: paths must precede expression: Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] cp: missing file operand
find /home/username/folder -type f -name "*.doc" -print0 \ | xargs -0 cp -t /home/username/doclist/
or even
find /home/username/folder -type f -name "*.doc" \ -exec cp -t /home/username/doclist/ '{}' + Also no. Result is: find: paths must precede expression: -exec Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
Have a nice day, Berny
Thanks for taking the time. Gustav.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/29/2015 11:49 AM, Gustav Degreef wrote:
On 10/28/2015 08:39 PM, Bernhard Voelker wrote:
On 10/28/2015 08:01 PM, Gustav Degreef wrote:
I need to pipe the names and locations of files I find by:
find /home/username/folder -type f -name "*.doc"
to:
cp *.doc /home/username/doclist/ cp --help | grep -- --target -t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY
Therefore, the command boils down to:
find /home/username/folder -type f -name "*.doc" \ | xargs cp -t /home/username/doclist/
or (for unlucky file names with blanks etc.)
Does not work. Result is:
find: paths must precede expression: Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] cp: missing file operand
find /home/username/folder -type f -name "*.doc" -print0 \ | xargs -0 cp -t /home/username/doclist/
or even
find /home/username/folder -type f -name "*.doc" \ -exec cp -t /home/username/doclist/ '{}' + Also no. Result is: find: paths must precede expression: -exec Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
Have a nice day, Berny
Thanks for taking the time. Gustav.
I just tried the first 2 above and both of these work for me???? Mark -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/29/2015 03:57 PM, Mark Hounschell wrote:
cp --help | grep -- --target
-t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY
Therefore, the command boils down to:
find /home/username/folder -type f -name "*.doc" \ | xargs cp -t /home/username/doclist/
or (for unlucky file names with blanks etc.)
Does not work. Result is:
find: paths must precede expression: Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] cp: missing file operand
find /home/username/folder -type f -name "*.doc" -print0 \ | xargs -0 cp -t /home/username/doclist/
or even
find /home/username/folder -type f -name "*.doc" \ -exec cp -t /home/username/doclist/ '{}' + Also no. Result is: find: paths must precede expression: -exec Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
I just tried the first 2 above and both of these work for me???? Probably I am not executing the command you intend. Is the following one command, or one command followed by another?
I executed this (all on one line): find /home/username/folder -type f -name "*.doc" \ | xargs cp -t /home/username/doclist/ Gustav. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/29/2015 07:28 PM, Gustav Degreef wrote:
Probably I am not executing the command you intend. Is the following one command, or one command followed by another?
I executed this (all on one line): find /home/username/folder -type f -name "*.doc" \ | xargs cp -t /home/username/doclist/
If you put it on one line, then just omit the '\' which I added here as line continuation character because I split the command on 2 lines for better formatting in the mail. Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (6)
-
Andrei Borzenkov
-
Bernhard Voelker
-
Carlos E. R.
-
Gustav Degreef
-
Mark Hounschell
-
Ruben Safir