View previous topic :: View next topic |
Author |
Message |
chrooted n00b
Joined: 06 Jun 2008 Posts: 55
|
Posted: Wed Oct 15, 2008 8:36 am Post subject: find / xargs problem [solved] |
|
|
What's wrong with this command?
find . -type f -maxdepth 1 | xargs ls -latrh | head -n 10 -exec cp {} /test \;
head: invalid option -- e
Try `head --help' for more information.
find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.
xargs: ls: terminated by signal 13
Last edited by chrooted on Wed Oct 15, 2008 11:05 am; edited 1 time in total |
|
Back to top |
|
|
massimo Veteran
Joined: 22 Jun 2003 Posts: 1226
|
Posted: Wed Oct 15, 2008 9:37 am Post subject: |
|
|
You used find's --exec in combination with head which has no such parameter. _________________ Hello 911? How are you? |
|
Back to top |
|
|
chrooted n00b
Joined: 06 Jun 2008 Posts: 55
|
Posted: Wed Oct 15, 2008 9:39 am Post subject: |
|
|
massimo wrote: | You used find's --exec in combination with head which has no such parameter. |
OK, but I would like to move the first 1000 files in a directory sorted by date to another directory, how else could I do that? |
|
Back to top |
|
|
massimo Veteran
Joined: 22 Jun 2003 Posts: 1226
|
Posted: Wed Oct 15, 2008 9:49 am Post subject: |
|
|
Code: | find . -maxdepth 1 -type f | xargs ls -t | head -n 1000 | xargs cp -t /test |
_________________ Hello 911? How are you? |
|
Back to top |
|
|
chrooted n00b
Joined: 06 Jun 2008 Posts: 55
|
Posted: Wed Oct 15, 2008 10:19 am Post subject: |
|
|
Thanks! Is there a way to sort them by creaton date?
Because in the destination directory /test there are not present the oldest files in the . folder.
I mean, I have some 2007 files and only the 2008 year are copied in there.
I would like to use -ltr option, but:
find . -maxdepth 1 -type f | xargs ls -ltr | head -n 1000 | xargs cp -t /test
cp: invalid option -- w
Try `cp --help' for more information
The sort must be from the oldest to the newest files. |
|
Back to top |
|
|
neysx Retired Dev
Joined: 27 Jan 2003 Posts: 795
|
Posted: Wed Oct 15, 2008 10:47 am Post subject: |
|
|
1. Do read the man pages
2. Don't ask the same question in several threads |
|
Back to top |
|
|
chrooted n00b
Joined: 06 Jun 2008 Posts: 55
|
|
Back to top |
|
|
timeBandit Bodhisattva
Joined: 31 Dec 2004 Posts: 2719 Location: here, there or in transit
|
Posted: Wed Oct 15, 2008 1:21 pm Post subject: |
|
|
Moved from Other Things Gentoo to Duplicate Threads.
See thread linked above. _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
Back to top |
|
|
|