awk print to file question
Hello
Im spliting a large file into small once based on the $4 in the big file. Then i want to make a script that prints some info from the "smaller file" (lets call it #1) into a other document (lets call it #2 document). The first stuff in the #2 should be a record that comes from the #1. But i only want to print that stuff once. If i do a normal {print $4} log.txt > test.txt it print the $4 once for every new line in log.txt. |
Hi,
I quite cannot grasp what you are actually trying to achieve. You are being very vague in your description, e.g. Quote:
Quote:
Since awk is a line editor that is the normal behavior. But you can 'workaround' that. So from what I have understood so far you do have a script that does what you want but you'd like to improve it, make it more effective. Maybe you should post what you have so far. This will then hopefully clear things up of what your goal is. Some sample data of the ?three? involved files would be helpful, too. What do they look before processing and what are they supposed to look afterwards. |
Ok i will try to make it a bit more simple.
I have one log file (in raw syslog format) from a special host, example 192.168.1.1. Im trying to build a script that extract some info from that file to a other file (acctuly a html page). I want the first line in the html page to be like "Stats for $4". But if i run it with {print "Stats for" $4) it will print Stats for 192.168.1.1 each time for every line, witch i dont want. And i cant really use it in BEGIN becouse BEGIN dont read from the file (ex {print "yo" $4} in BEGIN just print yo. |
Find it, simple stuff ;) NR == 1 { print "test" }
|
All times are GMT -5. The time now is 11:55 PM. |