[BL] DOS & Shell Scripting Guide 41
Lee Forrest
lforrestster at gmail.com
Fri Feb 2 13:00:24 EST 2007
On Sat, Feb 03, 2007 at 01:55:10PM +1300, 3aoo-cvfd at dea.spamcon.org wrote:
> Lee Forrest wrote:
> >
> > Haven't figured out how to neatly format the above
> > without resorting to utilities not standard to BL.
>
> printf ?
I can use it a little bit, but don't know how to make it do the above. Here's
the code for the list below:
clear
num=1
set "/" "/bin" "/dev" "/etc" "/home" "/lib" "/proc" "/root" "/sbin" "/usr" "/var" ".." `/bin/ls -F`
for file in "$@" ; do
printf "%s[${num}] $file "
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 know I can get the columns and rows of someone's screen with 'stty size', and divide the
number of files by 4 with 'expr NUM / 4'....
Do you know how to turn that mess into, say, 4 neat columns, with printf? I'd love to be able
to do that.
I have the manpage and a C reference for the other escapes. It's just that my Greek is a little
rusty :-\
Thanks,
Lee
--
BasicLinux: Small is Beautiful
http://www.basiclinux.com.ru
More information about the BasLinux
mailing list