for-loop for every folder in a directory, excluding some of them

后端 未结 5 1581
野趣味
野趣味 2020-12-06 06:46

Thank you very much in advance for helping!

I have this code in bash:

for d in this_folder/*    
    do    
        plugin=$(basename $d)
        ech         


        
5条回答
  •  悲哀的现实
    2020-12-06 06:55

    You could use find and awk to build the list of directories and then store the result in a variable. Something along the lines of this (untested):

    dirs=$(find this_folder -maxdepth 1 -type d -printf "%f\n" | awk '!match($0,/^(global|plugins|css)$/)')
    for d in $dirs; do
        # ...
    done
    

    Update 2019-05-16:

    while read -r d; do
        # ...
    done < <(gfind  -maxdepth 1 -type d -printf "%f\n" | awk '!match($0,/^(global|plugins|css)$/)')
    

提交回复
热议问题