Page 1 of 1

print sequential number

Posted: 07 Oct 2010 03:53
by santhosh
hi help me please.
Input file:- ram.csv(it's comma sep)
Name NumStart NumEnd Price
sat 50 53 6RS
ram 74 77 11RS
jim 82 83 15RS

Output file:- out.txt
sat 50 6RS
sat 51 6RS
sat 52 6RS
sat 53 6RS
ram 74 11RS
ram 75 11RS
ram 76 11RS
ram 77 11RS
jim 82 15RS
jim 83 15RS

Help me in using batch script and using awk tool in windows (agerman kindly help me).

Re: print sequential number

Posted: 07 Oct 2010 04:57
by ghostmachine4

Code: Select all

C:\test>gawk -F"," "{ for(i=$2;i<=$3;i++) {print $1,i,$NF}}" OFS="," file
sat,50,6RS
sat,51,6RS
sat,52,6RS
sat,53,6RS
ram,74,11RS
ram,75,11RS
ram,76,11RS
ram,77,11RS
jim,82,15RS
jim,83,15RS

Re: print sequential number

Posted: 07 Oct 2010 07:26
by santhosh
Thanks Ghost its working fine.
And i want batch script too.