How to exclude some files from the loop in shell script [duplicate]
问题 This question already has answers here : for-loop for every folder in a directory, excluding some of them (5 answers) Closed 12 months ago . #! /bin/sh for file in $Files/*.txt; do chmod 777 $file done It will give permission 777 to all .txt files but I've 7 other .txt file for which I don't want to give 777 permission. How can I do that? 回答1: you can add a conditional check as below. As there's no clear attribute differentiating the files you want to exclude, you'd need to specifically check