tree脚本
时间:2005-07-25 来源:honbj
#! /bin/sh
echo $PWD
pre=$(echo $PWD | awk -F/ '{print NF}')
find $PWD -name "*" -o -name ".*" 2>/dev/null | sed -n '2,$p' | while read line; do
i=2
num=$(echo $line |awk -F/ '{print NF}')
num=$((num-pre+1))
while [ $i -lt $num ] ; do
echo -e "| c"
num=$((num-1))
done
file $line | grep directory >/dev/null 2>&1
#echo $?
if [ $? -eq 0 ]; then
echo -e "|-----""33[34m${line##*/}33[0m"
else
echo -e "|-----""33[32m${line##*/}33[0m"
fi
done
#!/bin/bash
T='gYw' # The test text
echo
echo " default 40m 41m 42m 43m 44m 45m 46m 47m"
## FGs 为前景(foreground)色, BG 为背景(background)色
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m'
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m'
' 36m' '1;36m' ' 37m' '1;37m';
do
FG=${FGs// /} # 去掉其中的空格
echo -en " $FGs 33[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do
echo -en " 33[$FG33[$BG $T 33[0m"
done
echo
done
echo