Exclude list of files from find

后端 未结 6 1893
北恋
北恋 2021-01-31 07:43

If I have a list of filenames in a text file that I want to exclude when I run find, how can I do that? For example, I want to do something like:

fi         


        
6条回答
  •  不思量自难忘°
    2021-01-31 08:04

    Josh Jolly's grep solution works, but has O(N**2) complexity, making it too slow for long lists. If the lists are sorted first (O(N*log(N)) complexity), you can use comm, which has O(N) complexity:

    find /dir -name '*.gz' |sort >everything_sorted
    sort skip_files >skip_files_sorted
    comm -23 everything_sorted skip_files_sorted | xargs . . . etc
    

    man your computer's comm for details.

提交回复
热议问题