unix - get different datetime when shell script is executing -


i have shell script(ksh) writes files xxxx unix directory through spool oracle table x.

table x having column having seq_no.the file should generated different seeq_no.

e.g.

table x data  seq_no,a,b,c 1,2,3,4 1,5,6,7 1,8,9,10 2,1,2,3 2,4,5,6 2,7,8,9 

the file name = test_${stamp}.csv

in case 2 files different timstamp should generated have 2 different seq_no in table x.

when script runs stamp = date +%y%m%d%h%m%s variable hold 1 value.so first file getting on writen second.

please tell me how can find current datetime when shell script in execution condition itself.

if question correctly, need have separate files each having records specific sequence number only.

if can change approach can try below:

  1. spool file, lets seq_file, query distinct seq nos.

     content of seq_file: 1 2 3 5 
  2. iterate on each line of seq_file , grep "^${seq}," , redirect output required file, may can calculate stamp2 variable use in final file name.

    while read seq    stamp2=`date +%y%m%d%h%m%s`    grep "^${seq}," test_${stamp}.csv >> ${seq}_$stamp2 done<seq_file 

Comments