Re: ls'ing dirs before files
On Mon, 29 Jul 2002 01:10:27 +0100, Carlos Sousa wrote:
>On Sun, 28 Jul 2002 18:49:26 -0500 Gary Turner <kk5st@swbell.net> wrote:
>
>> The more I think about, the handier that sounds. Until Herr Kringle
>> fills the stockings, here's another novice attempt. In .bashrc,
>>
>> alias dir='ls -al | grep ^d && ls -al | grep ^[^d]'
>
>1) only works without parameters (dir /tmp not possible)
True. It doesn't accept arguments, or switches, and doesn't have the
necessary validation tests anyway. Must cd to desired directory first.
>
>2) completely misses symlinks to directories elsewhere, which should
>appear in the dir group.
This won't segregate links-to-files-right-here from
links-to-files-over-there, but it will put all the links together.
'ls -al | grep ^d ; ls -al | grep ^l ; ls -al | grep ^[^dl]'
Note the use of ";" instead of "&&." Anding the commands is a fatal
logic error. Using the -a switch meant there were always directories,
so regular files were always tested. Testing for links (grep ^l) meant
failure if no links existed, and ls for regular files (actually a
default fall through for !directory && !link) never ran. You don't need
to slap me up side the head more than several times. I'll catch on
eventually. :)
--
gt kk5st@swbell.net
It ain't so much what you don't know that gets you in trouble---
it's what you do know that ain't so.--unk
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: