Dear Unix gurus,
I have to solve the following types of problem - which I'm hoping can
be solved more efficiently than my crude and inefficient ways of
solving. Basically I have lists in the order 20,000 records which I
need to run a SQL query involving 'WHERE' clause. My files/environment
is a Sun (OS 5.6) unix box.
SQL 'WHERE' clause can only accept 1000 records at a time - hence, I
need to split the list in individual files of 1000 records each.
Here is a sample input file - its a list, so each record is separated
by a new line character and there are no duplicates in the list.
InputFile
---------
100789A10
100789A11
100789A12
100789A13
...
...
887648A55
887648A56
887648A57
When I use the split command as shown below
split -1000 InputFile
The resulting files get named as
xaa
xab
xac
..
..
xgh
question 1: how can I make the starting and ending line numbers appear
in the resulting output files. For example
if my Input file name is InputFile and has 20000 records, I would like
the resulting Output files named as
InputFile_00000-01000
InputFile_01001-02000
..
..
InputFile_19001-20000
Upon running the split command, I now have 20 output files - each has
1000 records. I need to insert some text in each output file so to
convert them to .sql files. When I run the split command, the
resulting xaa, xab..etc files will obviously be in the same directory?
question - can anyone show me how to do this. An illustration is
below.
xaa (sample file)
100789A10
100789A11
100789A12
100789A13
...
...
887648A55
887648A56
887648A57
xaa.sql (resulting .sql file)
SELECT PART_NUMBER '|' DESCRIPTION FROM PARTS_TABLE where PART_NUMBER
IN (
'100789A10',
'100789A11',
'100789A12',
'100789A13',
'... ',
'... ',
'887648A55',
'887648A56',
'887648A57'
);
Thank you,
Sri