How to perform a for-each loop over all the files under a specified path?

前端 未结 4 507
粉色の甜心
粉色の甜心 2020-12-02 07:00

The following command attempts to enumerate all *.txt files in the current directory and process them one by one:

for line in \"find . -iname \'         


        
4条回答
  •  我在风中等你
    2020-12-02 07:49

    Use command substitution instead of quotes to execute find instead of passing the command as a string:

    for line in $(find . -iname '*.txt'); do 
         echo $line
         ls -l $line; 
    done
    

提交回复
热议问题