本文共 446 字,大约阅读时间需要 1 分钟。
Shell实现
1、find命令
find dir.yahoo.com/ -name '*.html' | less
2、for加if
foreach_dir(){for file in $1/*doif [ -d $file ]; thenforeach_dir $fileelse#do something herefidone}
Python实现
import osdef listalldir(path,level=0): for i in os.listdir(path): print ' '*(level+1) + i file = path + os.path.sep + i if os.path.isdir(file): listalldir(file,level+1)rootpath = os.path.abspath('.')print rootpathlistalldir(rootpath)
转载地址:http://ghntb.baihongyu.com/