redirecting print output to variable name in awk 
Author Message
 redirecting print output to variable name in awk

If I want to redirect the output of a print command in awk
to a file, that's fine, I just do:
        eg. print $1 > "filename"

But if I have a filename stored in a variable,
        eg. filename = ARGV[1]

is there a way of using that variable in the print output command?

Alison Tunley

**********************************************************************
Alison Tunley                
Phonetics Laboratory, Department of Linguistics    
University of Cambridge, Sidgwick Avenue              
Cambridge, CB3 9DA                      

homepage: http://www.*-*-*.com/ ~ajt20
tel: +44 1223 335026; fax: +44 1223 335053
**********************************************************************



Fri, 05 May 2000 03:00:00 GMT  
 redirecting print output to variable name in awk

Yes, the same way...

BEGIN { my_file = "my_file.txt" }

{
        print $1 > my_file

Quote:
}

--
Best regards,
 _ __                      _    ,   _ _ _
' )  )     /         _/_  ' )  /   ' ) ) )
 /--' ____/___/> __  /     /--/     / / / __,_  __  o _   ______
/  \_(_) /_) (__/ (_<__   /  ( o   / ' (_(_) (_/ (_<_/_)_(_) / <_

Robert H. Morrison                      Tel:   +49 721 9628 167
Software Development, Basis Team        FAX:   +49 721 9628 261



Quote:
> If I want to redirect the output of a print command in awk
> to a file, that's fine, I just do:
>         eg. print $1 > "filename"

> But if I have a filename stored in a variable,
>         eg. filename = ARGV[1]

> is there a way of using that variable in the print output command?



Fri, 05 May 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Outputting info from awk and using the info to name the awk output file

2. Naming the output file based on awk script variable

3. How to redirect the standard output to a REXX-variable

4. redirect python output + extension type with own print method = FAILS

5. Redirect file output into variables

6. Use awk to print syslog output to terminal with colors

7. Save awk output as global variable

8. Using a variable name for a variable name??

9. awk print variable on a new line

10. print several variables with awk

11. how to print a shell variable in awk states

12. accessing a shell variable in an awk print statement

 

 
Powered by phpBB® Forum Software