shell 遍歷當前目錄以及所有子目錄下文件


#!/bin/bash file_count=0 folder_count=0 function TRAVEL_ALL_FILE(){    for file in *; do
        if [ -f ${file} ];then #normal file echo ${file} ((file_count++)) elif [ -d ${file} ];then #dir cd ${file} ((folder_count++)) TRAVEL_ALL_FILE cd .. fi done } TRAVEL_ALL_FILE echo "There are $file_count files and $folder_count folders in : ";pwd    

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM