bash script read all the files in directory

后端 未结 3 758
花落未央
花落未央 2021-02-02 07:36

How do I loop through a directory? I know there is for f in /var/files;do echo $f;done; The problem with that is it will spit out all the files inside the directory

3条回答
  •  离开以前
    2021-02-02 08:23

    You can go without the loop:

    find /path/to/dir -type f -exec /your/first/command \{\} \; -exec /your/second/command \{\} \; 
    

    HTH

提交回复
热议问题