LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-26-2016, 05:50 AM   #1
zakur0
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

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

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

Ok that was fast apparently I had to -t before destination
Code:
 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
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

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


Reply


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


All times are GMT -5. The time now is 10:05 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration