[wellylug] a bit of data bashing

Grant McLean grant at mclean.net.nz
Tue Mar 24 10:07:48 NZDT 2015


On Tue, 2015-03-24 at 09:52 +1300, edouard chalaron wrote:
> HI Grant
> 
> Not too familiar with the seq command.

In it's simplest form, you pass it 2 numbers and it outputs a series of
lines counting from the first number to the second:

$ seq 1 10
1
2
3
4
5
6
7
8
9
10
$

>  However the %06g is important.

Indeed. That's a printf-style format argument that says the numbers
should be padded to 6 digits with leading zeros - which seemed to be
roughly what you asked for.

Anything else you put in the -f argument will be passed through as a
string literal (e.g. the 'file' on the beginning or the '.whatever' on
the end of: 'file%06g.whatever').

> Can you show me how to incorporate this seq command in a script ? A bit
> lost on this one I must confess

>From your initial question, I thought you just wanted to generate a
file, so scripting not strictly necessary.

However, if you want to use it in a script you could do something like:

    for file in `seq -f 'file%06g.whatever' 1 19`
    do
        echo $file
    done

Cheers
Grant




More information about the wellylug mailing list