Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Arg list too long - trying to move some files to a sub directory

  • 06-03-2014 4:10pm
    #1
    Registered Users, Registered Users 2 Posts: 1,763 ✭✭✭


    Have a directory with over 100,000 files in it. I've created a sub directory called archive_2013 and want to put last years data into it. The files have the extension .bkp

    I've tried to use the following command ( 70 days is close enough to start of year)

    find *.bkp -mtime +70 -type f -print | xargs -i{} mv {} /archive_2013

    I keep getting "Arg list too long" , any ideas ?

    I've also tried

    find *.bkp -mtime +70 -type f -print -exec mv "{}" /archive_2013 \;

    but same error.

    Thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 1,110 ✭✭✭Skrynesaver


    find ./ -name \*.bkp -mtime +70 -type f -exec mv {} /archive_2013\;
    

    You were asking the shell to expand *.bkp as an arg list for the find command


  • Registered Users, Registered Users 2 Posts: 1,763 ✭✭✭ShatterProof


    Thanks but

    find ./ -name \*.bkp -mtime +70 -type f -exec mv {} /archive_2013\;

    is giving the error "find: incomplete statement" (meant to say this is AIX not sure if it makes a difference)


  • Registered Users, Registered Users 2 Posts: 5,053 ✭✭✭opus


    Is this any use?
    find . -maxdepth 1 -type f -name "*.bkp" -exec mv {} /archive_2013 \;
    

    Don't have a directory with millions of files to test it.


  • Registered Users, Registered Users 2 Posts: 6,285 ✭✭✭bonzodog2


    You could move all of them, and move the newer ones back (a smaller list).


  • Registered Users, Registered Users 2 Posts: 2,755 ✭✭✭niallb


    find *.bkp -mtime +70 -type f -print -exec mv "{}" /archive_2013 \;

    Put single quotes around the name expression and careful with slashes and backslashes. Use -print0 in case there are spaces or weird things in the names.

    find . -name '*.bkp' -mtime +70 -type f -print0 | xargs mv "{}" archive_2013 \;

    AIX can be odd with expansion, and I think I remember single quotes being the magic bullet in a similar situation. Try that and see if you get a different error at least!

    Alternatively, find a smaller subset of files and try for
    mv *201001*.bkp archive_2013
    mv *201202*.bkup archive_2013
    and so on, but better to find the right command!


  • Advertisement
Advertisement