More efficient way to find & tar millions of files

前端 未结 9 601
一向
一向 2021-01-30 17:53

I\'ve got a job running on my server at the command line prompt for a two days now:

find data/ -name filepattern-*2009* -exec tar uf 2009.tar {} ;
9条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 18:54

    To correctly handle file names with weird (but legal) characters (such as newlines, ...) you should write your file list to filesOfInterest.txt using find's -print0:

    find -x data -name "filepattern-*2009*" -print0 > filesOfInterest.txt
    tar --null --no-recursion -uf 2009.tar --files-from filesOfInterest.txt 
    

提交回复
热议问题