How to loop through file names returned by find?

前端 未结 13 1343
野性不改
野性不改 2020-11-22 04:20
x=$(find . -name \"*.txt\")
echo $x

if I run the above piece of code in Bash shell, what I get is a string containing several file names separated

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 04:37

    How about if you use grep instead of find?

    ls | grep .txt$ > out.txt
    

    Now you can read this file and the filenames are in the form of a list.

提交回复
热议问题