shell命令tree
生活随笔
收集整理的這篇文章主要介紹了
shell命令tree
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在Windwows下很喜歡tree命令,在CenntOS下也有這條命令,在網上找到了源代碼和一段簡單的腳本,
完整的tree源代碼可以在這里下載:?ftp://mama.indstate.edu/linux/tree/
簡易的tree腳本如下:
#!/bin/sh ####################################################### # UNIX TREE # # Version: 2.3 # # File: ~/apps/tree/tree.sh # # # # Displays Structure of Directory Hierarchy # # ------------------------------------------------- # # This tiny script uses "ls", "grep", and "sed" # # in a single command to show the nesting of # # sub-directories. The setup command for PATH # # works with the Bash shell (the Mac OS X default). # # # # Setup: # # $ cd ~/apps/tree # # $ chmod u+x tree.sh # # $ ln -s ~/apps/tree/tree.sh ~/bin/tree # # $ echo "PATH=~/bin:\${PATH}" >> ~/.profile # # # # Usage: # # $ tree [directory] # # # # Examples: # # $ tree # # $ tree /etc/opt # # $ tree .. # # # # Public Domain Software -- Free to Use as You Like # # http://www.centerkey.com/tree - By Dem Pilafian # #######################################################echo if [ "$1" != "" ] #if parameter exists, use as base folderthen cd "$1"fi pwd ls -R | grep ":$" | \sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' # 1st sed: remove colons # 2nd sed: replace higher level folder names with dashes # 3rd sed: indent graph three spaces # 4th sed: replace first dash with a vertical bar if [ `ls -F -1 | grep "/" | wc -l` = 0 ] # check if no foldersthen echo " -> no sub-directories"fi echo exit轉載于:https://www.cnblogs.com/java20130726/archive/2013/01/29/3218684.html
總結
以上是生活随笔為你收集整理的shell命令tree的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 几百余次恶意传播不实信息 小鹏起诉车主赔
- 下一篇: PC/手机双平台通吃!米哈游新作《绝区零