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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running gawk program in DOS batch file 1

Status
Not open for further replies.

richardii

Programmer
Jan 8, 2001
104
GB
I'm trying to run an awk program from a DOS batch file. I want to output each xms file in my directory to a txt file. This:

for %%f in ( *.xms ) do c:\awk\gawk -f c:\awk\cann.awk >*.txt

doesn't work. Does anyone know how to loop through the files of type xms and output each to a txt? More of a DOS question, but.....

Thanks very much.
 

Hi, richardii!

I often use GNU awk for DOS (GNU, thanks! Jesus loves you). It works good. But program in command line must be between double quotes.

Something is wrong in you for statement, I think: you can't redirect output of the command into many files (*.txt), only in one file. For example, this for statement works:

for %1 in (*.xms) do type %1 > output.txt

I suggest you to do redirection inside awk script. You can also use this .bat file:

@echo off
if %1.==. exit
c:\awk\gawk -f c:\awk\cann.awk %1

If you don't know how to create filename.txt from filename.xms, you can ask me; I know.

Bye!

KP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top