Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run an executable .bat from an awk

Status
Not open for further replies.

dbehera

Programmer
May 31, 2005
8
US
I have a transform.bat which converts 1 line of input text to FIXML format.

How do I use this in a awk or in a loop to convert 1000 lines of input text to FIXML format output file.

TRX100 A 100 212 200414 ->infile.txt

transform.bat infile.txt

Output is infile.txt.transform

<FIXML> <TTT=1000> <RPT=2100>....


Now I have a file infile1.txt which has multiple lines.

But transform.bat can take only one line per execution.

Thanks for your help.
 
The transform.bat calls java program someone else wrote.

I am just using it.
 
So you want to write a awk statement that grabs one line and passes that to a batch script??

 
yes ... one line into a file and then pass that file to a batch file.
 
This would mean that you would have equal number of files as the number of lines that you want to feed to the batch file.

If that is the case all you do is read the file using cat and then pipe that to awk and print $0 which grabs the whole line from the file and redirect the line to some other file. Feed this file to the batch script.

You may have to write a shell script to do this. alternatively if you already have the file that you want to read line by line try

#!/usr/bin/ksh
count=0
cat infile.txt | while read line
do
count=`expr $count + 1`
echo $line>file$count
done

This will read from infile.txt and create files one line per file. The output file would be file1 to file(n) depending on the number of lines in infile.

HTH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top