Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
find / xargs problem [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Duplicate Threads
View previous topic :: View next topic  
Author Message
chrooted
n00b
n00b


Joined: 06 Jun 2008
Posts: 55

PostPosted: Wed Oct 15, 2008 8:36 am    Post subject: find / xargs problem [solved] Reply with quote

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
View user's profile Send private message
massimo
Veteran
Veteran


Joined: 22 Jun 2003
Posts: 1124
Location: Austria

PostPosted: Wed Oct 15, 2008 9:37 am    Post subject: Reply with quote

You used find's --exec in combination with head which has no such parameter.
_________________
Hello 911? How are you?
Back to top
View user's profile Send private message
chrooted
n00b
n00b


Joined: 06 Jun 2008
Posts: 55

PostPosted: Wed Oct 15, 2008 9:39 am    Post subject: Reply with quote

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
View user's profile Send private message
massimo
Veteran
Veteran


Joined: 22 Jun 2003
Posts: 1124
Location: Austria

PostPosted: Wed Oct 15, 2008 9:49 am    Post subject: Reply with quote

Code:
find . -maxdepth 1 -type f | xargs ls -t | head -n 1000 | xargs cp -t /test

_________________
Hello 911? How are you?
Back to top
View user's profile Send private message
chrooted
n00b
n00b


Joined: 06 Jun 2008
Posts: 55

PostPosted: Wed Oct 15, 2008 10:19 am    Post subject: Reply with quote

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
View user's profile Send private message
neysx
Retired Dev
Retired Dev


Joined: 27 Jan 2003
Posts: 795

PostPosted: Wed Oct 15, 2008 10:47 am    Post subject: Reply with quote

1. Do read the man pages
2. Don't ask the same question in several threads
Back to top
View user's profile Send private message
chrooted
n00b
n00b


Joined: 06 Jun 2008
Posts: 55

PostPosted: Wed Oct 15, 2008 11:05 am    Post subject: Reply with quote

Ok.

Solved in here: https://forums.gentoo.org/viewtopic-p-5248197.html#5248197
Back to top
View user's profile Send private message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2671
Location: here, there or in transit

PostPosted: Wed Oct 15, 2008 1:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Duplicate Threads All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum