Bash: how to traverse directory structure and execute commands?

前端 未结 6 1649
半阙折子戏
半阙折子戏 2021-01-12 06:40

I have split a large text file into a number of sets of smaller ones for performance testing that i\'m doing. There are a number of directories like this:

/h         


        
6条回答
  •  情书的邮戳
    2021-01-12 07:05

    As others have suggested, use find(1):

    # Find all files named 'myfile.chunk.*' but NOT named 'myfile.chunk.*.processed'
    # under the directory tree rooted at base-directory, and execute a command on
    # them:
    find base-directory -name 'output.*' '!' -name 'output.*.processed' -exec ./myexecutable -i '{}' -o '{}'.processed ';'
    

提交回复
热议问题