Skip to Content.
Sympa Menu

baslinux - Re: [BL] Simple File Manager 44

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: Lee Forrest <lforrestster AT gmail.com>
  • To: BasicLinux List <baslinux AT lists.ibiblio.org>
  • Subject: Re: [BL] Simple File Manager 44
  • Date: Fri, 2 Feb 2007 22:41:39 +0000

On Sat, Feb 03, 2007 at 06:43:13PM +1300, 3aoo-cvfd AT dea.spamcon.org wrote:
> > > clear
> > > num=1
> > > set "/" "/bin" "/dev" "/etc" "/home" "/lib" "/proc" "/root" "/sbin"
> > > "/usr" "/var" ".." `/bin/ls -F`
> > > for file in "$@" ; do
> > > printf "%-20s" "[${num}] $file"
> > > [ `dc $num 4 mod` = 0 ] && echo
> > > num=`expr $num + 1`
> > > done
> >
> > [11] /var [: 0: unknown operand
> >
> > It turns out to be a bug in the dc in BL3 busybox.
>
> You can get the script to work on BL3, by replacing the
> dc line with this:
> ------------------------------------------------------------
> case $num in 4|8|12|16|20|24|28|32|36|40|44|48|52|56|60)echo
> esac
> ------------------------------------------------------------
>
> It's not very elegant, but at least it works on BL3.

I beg to differ. That is a _most_ elegant hack.

This works beautifully:

#!/bin/sh

clear
num=1
set "/" "/bin" "/dev" "/etc" "/home" "/lib" "/proc" "/root" "/sbin" "/usr"
"/var" ".." `/bin/ls -F`
for file in "$@" ; do
printf "%-20s" "[${num}] $file"
case "$num" in
4|8|12|16|20|24|28|32|36|40|44|48|52|56|60) echo ;;
esac
num=`expr $num + 1`
done

----------------

[1] / [2] /bin [3] /dev [4] /etc

[5] /home [6] /lib [7] /proc [8] /root

[9] /sbin [10] /usr [11] /var [12] ..

[13] cardmgr [14] chat [15] install-to-hd [16] lsof

[17] nc@ [18] pppd [19] pure-authd [20] pure-ftpd

[21] pure-ftpwho [22] pure-mrtginfo [23] pure-quotacheck[24]
pure-uploadscript
[25] receive [26] send [27] tcpdump [28] special/

I sure appreciate the help, Steven. Now I will sit down and play
with your formatting improvements until I understand them.

I saw your posts on dc, about needing the p option. I'd have never figured
that
out.

But I like your case hack (it _would_ be more portable) and now I
have _two_ ways to do the same thing, which means that I'll have
an easier time understanding what's going on.

And I now know I have a commandline calculator.

Although I discovered you could do that with calctool, basically.

Now give me one good reason why I should keep calctool around since I
have dc! I do not do fancy mathemtics. Simple algebra is about it, and
all that needs is * and / and + and - and square root, all of which
dc does....


Lee

--
BasicLinux: Small is Beautiful
http://www.basiclinux.com.ru





Archive powered by MHonArc 2.6.24.

Top of Page