Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-26-2016, 05:50 AM   #1
LQ Newbie
Registered: Jul 2016
Posts: 1

Rep: Reputation: Disabled
Find with shuf to cp with backup

So I ended up scripting this but I wanted to know what I did wrong in the oneliner..

I need to pick up images from a huge collection at random , but most images have the same name ex. left_1.png , up_1.png etc so I tried this

 find . -type f -name "*.png" | shuf -n 50 | xargs cp --backup=existing /to/dest/path
but I would get as an error

 cp:target path/to/image/up.png is not a directory
Thanks Tasos

Ok that was fast apparently I had to -t before destination
 find . -type f -name "*.png" | shuf -n 50 | xargs cp --backup=existing  -t /to/dest/path
srr for that :P

Last edited by zakur0; 07-26-2016 at 05:56 AM. Reason: Found solution
Old 07-26-2016, 05:54 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,394

Rep: Reputation: 409Reputation: 409Reputation: 409Reputation: 409Reputation: 409
use -t /to/dest/path option for cp
       -t, --target-directory=DIRECTORY
              copy all SOURCE arguments into DIRECTORY
1 members found this post helpful.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Does 'shuf' seed itself with a zero? Dafydd Linux - General 2 10-26-2013 05:35 PM
Backup using rsync and/or find? manya Linux - General 2 10-28-2011 04:56 AM
Backup using find exec tar comeatmanish Linux - General 5 09-13-2011 07:20 AM
[SOLVED] Backup One Liner find xargs cp metallica1973 Linux - Server 7 05-30-2011 09:50 PM
System backup - I find it very confusing - help sofasurfer Debian 4 06-07-2006 01:25 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:08 AM.

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