Kod: Markera allt
#! /bin/bash
#
function usage {
cat << EOD
lsd [-a|--all] [-l|--long] [-t] [-r] [DIRECTORY]
Options:
-a | --all List all directories, including those beginning with "."
-l | --long Long listing, including information
-t Sort in time-order (can only be used together with -l)
-r Sort in reverse order (can only be used together with -l)
EOD
}
#
#####################################################################
TEMP=`getopt -oaltr --long all,long -n $(basename $0) -- "$@"`
if [[ $? -ne 0 ]]; then
usage
fi
eval set -- "$TEMP"
ALL=false
OPT=""
LONG=false
CMDNAME=$(basename $0)
while true; do
case $1 in
-a|--all)
ALL=true
shift
;;
-l|--long)
LONG=true
shift
;;
-t)
OPT=$OPT" -t"
shift
;;
-r)
OPT=$OPT" -r"
shift
;;
--)
shift
break
;;
*)
echo "-Got a star..."
shift
;;
esac
done
P1=$1
P2=$2
P3=$3
P4=$4
#
echo
if [[ $LONG == true ]]; then
if [[ -z $P1 ]]; then
if [[ $ALL == true ]]; then
#ls -lad --color=auto */. | sed 's=/.==g'
ls -Al $OPT --indicator-style=none --color=auto | grep "^d"
else
#ls -ld --color=auto */. | sed 's=/.==g'
ls -l $OPT --indicator-style=none --color=auto | grep "^d"
fi
else
if [[ $ALL == true ]]; then
#ls -lad --color=auto $P1/*/. | sed 's=\/\.==g'
ls -Al $OPT --indicator-style=none --color=auto $P1 | grep "^d"
else
#ls -ld --color=auto $P1/*/. | sed 's=\/\.==g'
ls -l $OPT --indicator-style=none --color=auto $P1 | grep "^d"
fi
fi
else
if [[ -z $P1 ]]; then
if [[ $ALL == true ]]; then
find -L . -maxdepth 1 -type d | awk -F "./" '{ print $2 }' | sort | column
else
find -L . -maxdepth 1 -type d -name "[!.]*" | awk -F "./" '{ print $2 }' | sort | column
fi
else
if [[ $ALL == true ]]; then
find -L $P1 -maxdepth 1 -type d -not -name $P1 | sort | column
else
find -L $P1 -maxdepth 1 -type d -name "[!.]*" -not -name $P1 | sort | column
fi
fi
fi
echo