[BL] Simple File Manager (was: DOS & Shell Scripting Guide)

Lee Forrest lforrestster at gmail.com
Fri Feb 2 15:23:12 EST 2007


On Sat, Feb 03, 2007 at 03:54:02PM +1300, 3aoo-cvfd at dea.spamcon.org wrote:
> Lee Forrest wrote:
> >
> > Do you know how to turn that mess into, say, 4 neat columns, 
> > with printf? I'd love to be able to do that.
> 
> 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

I've heard of dc (used bc on my debian at a very basic level) and
know it is a similar app, but didn't even know I had it here on
BL3 (hangs head in shame).

I tested the above and got results like this:

[5] /home           [: 0: unknown operand
[6] /lib            [: 0: unknown operand
[7] /proc           [: 0: unknown operand
[8] /root           [: 0: unknown operand
[9] /sbin           [: 0: unknown operand
[10] /usr           [: 0: unknown operand
[11] /var           [: 0: unknown operand

That's a test error, right?

I tried using "-eq" instead of "=" and "''" instead of "0", and 

N=`dc $num 4 mod` 
[ $N  = 0 ] && echo   

Got the same error with "-eq" and this below with "''":

[: unknown operand

dc $num 4 mod

on the commandline yields _no_ output, regardless of the number I substitute
for $num. It just returns the prompt.

I've got the dc manpage from the web, and am looking it over now.

What am I missing, Steven?

Lee

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




More information about the BasLinux mailing list