print sequential number

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
santhosh
Posts: 41
Joined: 02 Aug 2010 05:10

print sequential number

#1 Post by santhosh » 07 Oct 2010 03:53

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).

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

Re: print sequential number

#2 Post by ghostmachine4 » 07 Oct 2010 04:57

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

santhosh
Posts: 41
Joined: 02 Aug 2010 05:10

Re: print sequential number

#3 Post by santhosh » 07 Oct 2010 07:26

Thanks Ghost its working fine.
And i want batch script too.

Post Reply