Shell script recursively prints all directory files in the specified directory

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/"]; ThenPrintf"$DIR 1/$line"#递归调用.        fi Done}printf.#!/bin/bash#这个的实现递归总是无法递归到第一层. PRINTF() {ls | while ReadLine Do  pwd#测试当前路径. [- D./$line] &&{Echo $line        CD./$line     #这里有问题, there's no recursion, and it's going to the next level.    #所以就出现了我上面的解法. PRINTF} Done}printf

Shell script recursively prints all directory files in the specified directory

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.