CentOS系统下列出文件树和目录树

浏览次数:1481 关键词 ( 文件  目录  系统  CentOS  )

centos下列出当前目录的文件树和目录树:
当前目录:

[root@10.10.90.97 ncftp]# pwd
/usr/local/ncftp 文件树:
[root@10.10.90.97 ncftp]# find . -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/'                
|---bin
|    |---ncftpls
|    |---ncftpput
|    |---ncftpbookmarks
|    |---ncftpbatch
|    |---ncftpget
|    |---ncftpspooler
|    |---ncftp
|---etc 目录树:
[root@10.10.90.97 ncftp]# find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/'       
|---bin
|---etc