linux tree 命令

http://www.centerkey.com/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 folder
then 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 folders
then echo " -> no sub-directories"
fi
echo
exit




-------------------------------------------------------------------------------------------------------------------------------------------------------------------
下载安装:http://mama.indstate.edu/users/ice/tree/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值