For Programmers: Free Programming Magazines  


Home > Archive > AWK > March 2007 > GAWK









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author GAWK
gvarvind@gmail.com

2007-03-01, 7:57 am

am using GAWK(windows), i want to list files in a current directory &
i want to redirect all the listing files to a file hw can i do
it.......................? pls reply....

Ted Davis

2007-03-01, 6:58 pm

On 1 Mar 2007 04:24:48 -0800, gvarvind@gmail.com wrote:

>am using GAWK(windows), i want to list files in a current directory &
>i want to redirect all the listing files to a file hw can i do
>it.......................? pls reply....


The only way to use gawk to do this is to wrap it around a shell
command - however, there are a wide variety of options for generating
the list, and of course processing it in gawk once you have it. The
command
dir /a:-d /b > file
from the CMD prompt creates a file containing a list of file names in
alphabetical order. Used inside gawk this would be

BEGIN{
Command = "dir /a:-d /b > file"
system( Command )
}

if you wanted to process the list in gawk, then

BEGIN{
Command = "dir /a:-d /b"
while( ( Command | getline ) > 0 ) {
print $0
}
}

illustrates one way. See DIR /? at the CMD prompt for more
information on formatting the DIR command.

--
T.E.D. (tdavis@gearbox.maem.umr.edu) Remove "gearbox.maem" to get real address - that one is dead
Ed Morton

2007-03-01, 6:58 pm

gvarvind@gmail.com wrote:
> am using GAWK(windows), i want to list files in a current directory &
> i want to redirect all the listing files to a file hw can i do
> it.......................? pls reply....
>


awk is a tool for manipulating text, not for performing file operations.
That's not an awk question, it's an OS question. Ask in a windows NG.

Ed.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com