Use seq or jot to do repetitive numbering
I just now had to clean up some tables in a PostgreSQL database. The prior DBA thought that it would be good to split up tables into lx1, lx2, lx3 up to lx20. After I combined all the tables together, I needed to drop the originals. I could have written a Perl program to generate a series of drop table lx1; commands to feed into the psql command-line client, but instead I used the seq tool:
$ seq -f'drop table lx%g;' 1 20 drop table lx1; drop table lx2; ... drop table lx20;
If you don't have seq on your system, as on Mac OS X, you probably have jot, as in:
jot -w'drop table lx%g;' 20 1
Then again, if you just have to do it in Perl:
perl -le'print qq{drop table lx$_;} for 1..20'
but I like to use other tools than the Swiss Army Chainsaw sometimes.
Categories:
0 TrackBacks
Listed below are links to blogs that reference this entry: Use seq or jot to do repetitive numbering.
TrackBack URL for this entry: http://perlbuzz.com/cgi-bin/mt/mt-tb.cgi/357
Leave a comment