Shell script recursively prints all folder files in the specified folder

Source: Internet
Author: User
Tags shebang

#!/bin/bash#递归打印当前文件夹下的全部文件夹文件. PRINTF() {ls $| while ReadLine#一次读取每一行放到line变量中 Do[- D  $/$line] && {dir="$/$line"         Echo $DIR} dir1= ' DirName$DIR`#求路径. A= ' Ls-f$DIR 1| grep/| Grep"\<$line\>"` #推断line是不是一个文件夹. 

if [ " $A " = = " $line /"];then PRINTF " $DIR 1 / $line " #递归调用. fi done }printf. #!/bin/bash #这个的实现递归总是无法递归到第一层.

PRINTF(){ ls | while read line do pwd#測试当前路径。 [ -d ./$line ] &&{ echo $line cd ./$line #这里有问题。还没有递归就已经进入下一层了, #所以就出现了我上面的解法。 PRINTF } done}PRINTF

Shell script recursively prints all folder files in the specified folder

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.