å› ä¸ºæƒ³ç”ŸæˆGrails创建的目录结构,就å°è¯•ls命令,å‘现ä¸èƒ½æ»¡è¶³æˆ‘çš„è¦æ±‚(能力ä¸å¤Ÿï¼‰ï¼Œç½‘上找到这么一个脚本Tree.sh,感觉ä¸é”™ï¼Œè¿™é‡Œè´¡çŒ®ä¸‹ï¼Œé¡ºä¾¿è¯´ä¸‹å®‰è£…过程ä¸ç¢°åˆ°çš„一个å°é—®é¢˜ã€‚
我在Ubuntu下直接下载tree.sh并按è¦æ±‚安装,然åŽè¿è¡Œtree,得到如下错误:
/bin/sh^M: bad interpreter: No such file or directory
一时没有了主æ„,还是googleå§ï¼Œç»“果很少,但ä¸æ˜¯é›¶ï¼Œæ‰“开页é¢ä¸€çœ‹ï¼Œä¸çŸ¥å“ªå›½è¯è¨€ï¼Œä½†ç¨€é‡Œç³Šæ¶‚地感觉是文本文件的类型问题,想了想,还是自己创建个tree文件,然åŽæŠŠtree.sh里的内容copy过æ¥å¥½äº†ï¼Œè¿™æ‹›çš„确有效,ä¸ç„¶è¿˜è¦æ‰¾å·¥å…·æ¥è½¬æ¢ï¼Œå› 为我还ä¸çŸ¥é“什么工具能åšè¿™æ ·çš„转æ¢å‘¢ï¼ˆLinux刚刚入门ä¸åˆ°ä¸€ä¸ªæ˜ŸæœŸï¼‰ã€‚
#!/bin/sh
#######################################################
# UNIX TREE #
# File: ~/apps/tree/tree.sh #
# Version: 2.1 #
# Displays Structure of Directory Hierarchy #
# —————————————– #
# This tiny script uses “ls”, “grep”, and “sed” #
# in a single command to show the nesting of #
# sub-directories. #
# #
# Setup: #
# % cd ~/apps/tree #
# % chmod u+x tree.sh #
# % ln -s ~/apps/tree/tree.sh ~/bin/tree #
# #
# Usage: #
# % tree [directory] #
# #
# Examples: #
# % tree #
# % tree /etc/opt #
# % tree .. #
# #
# Public Domain Software — Free to Use as You Like #
# http://www.centerkey.com/tree #
#######################################################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
or
aptitude install tree