paul jakma asked me this today and i've often wanted to do similar things.
suddenly today i came up with an easier way then using expr.
On Tue, May 02, 2000 at 07:52:04PM +0100, Paul Jakma wrote:
> how do you do numerical expansion in sh/bash, ie
>> i want a for loop to iterate a variable through 001 to 254. In BASIC you
> can do something like:
adjust the argument to head accordingly:
for f in `yes "" | head -2 | cat -n|sed 's/ /0/g;s/.*\(....\)$/\1/'`; do
echo $f
done
mmmmm. damn that's sexy!
if you can live without the 001, 002, 003; and just settle on 1, 2, 3 then
it's a bit easier:
for f in `yes "" | head -2 | cat -n`; do
echo $f
done
ah, any day that you can find yes useful is just great!
kevin
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!