[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Bash Script
- Subject: [ale] Bash Script
- From: dsj at dsj.net (David S. Jackson)
- Date: Sun, 7 Feb 1999 19:51:24 +0000
Hi,
Is there a way to show ONLY directories from ls? I couldn't think of a way,
so I wrote a little thing called "lsd".
<quote>
#!/bin/sh
# This script lists only directories in the current directory--I
# don't know how to make ls do that! So I wrote this little script.
curdir=${1:-$PWD}
echo $curdir # This is for debugging
for dirname in $(ls $curdir)
do
if [ -d $dirname ]; then echo -ne "\t $dirname"
fi
done
echo -e "\n"
</quote>
First, for some reason, I can't seem to get the script to act on the $1 argument.
When I enter
lsd /home
I should get all the directories in /home. But that doesn't happen. What
am I doing wrong?
Second, is there a way I can "echo" a line across the screen similar to ls
-C? It works the way I have it (with echo -ne) but the column doesn't wrap
evenly onto the next line; it breaks in the middle of a word. Any hints?
Thanks much!
Dave
--
David S. Jackson http://www.dsj.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"What is the best government? That which teaches us to govern
ourselves."
--Johann Wolfgang von Goethe