简体   繁体   中英

Find command, linux

find -type f -name "*.avi" -exec md5sum {} + > checklist.chk
find -type f -name "*.mp4" -exec md5sum {} + > checklist.chk

How to combine these two commands? 1. Either by combining both search terms in one command or 2. Both commands adding output to one file. Hope it's clear what I am trying to do.

find -type f \\( -name "*.avi" -o -name "*.mp4" \\) -exec md5sum {} + > checklist.chk

这里解释

For Both commands adding output to one file .You Can do:

find -type f -name "*.avi," -exec md5sum {} + >> checklist.chk
find -type f -name "*.mp4," -exec md5sum {} + >> checklist.chk

Output file will have results of first command first and then the results of second command.

You can use the -o option as OR operator in commands. So, you can do it like this.

find -type f -name "*.avi" -o -name "*.mp4" -exec md5sum {} + > checklist.chk

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