简体   繁体   中英

How to find some files and input them to another program in bash?

I have many files with long names and I want to pass some of them to a program.

find . -name *A*.b

gives me the files I want. Now I want to pass them to another program, something like:

program -input A1.b A87_24.b A22.b

Any suggestions?

If they're all in the current directory you can just call the program with the pattern. The shell will expand it and call the program with the matching file names.

program -input *A*.b

If you do indeed want to search recursively through subdirectories, use -exec . And make sure to quote the pattern so the shell doesn't expand it.

find . -name '*A*.b' -exec program -input {} +

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM