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

Need to output to a file and STDOUT 1

Status
Not open for further replies.

btriggs127

Technical User
Dec 1, 2000
16
US
I think the subject says it all. I have a script that runs a few commands and in the end the AWK script needs a date to go back to in this format YYYY-MM-DD, that has been taken care of thanks to other posts here. The log file then prints out the lines that are >= to the date. That is where I would like to send the out put to STDOUT and append the log file with that info as well. A small example is :

awk 'BEGIN {
printf &quot;Enter the month to go back to: &quot;;getline month < &quot;-&quot;
printf &quot;Enter the day to go back to: &quot;; getline day < &quot;-&quot;
printf &quot;Enter the year to go back to: &quot;; getline year < &quot;-&quot;}
$1 >= year&quot;-&quot;month&quot;-&quot;day {print}' /logfile >> /FINAL LOG FILE

This is where the >> to another log file makes it hang because it waits for input from the FINAL LOG FILE. If it is possible to have it wait for the input from STDIN, but then send the output to append the FINAL LOG FILE, my mission would be complete. Any assistence is greatly appreciated in advance.
Thanks;
-Brian
 
Brian-

You might try piping the output from awk to the &quot;tee&quot;
command. The tee command writes to STDOUT and to a
named file:

awk '

......

}' | tee -ai final_log_file # appends to the
# final log and
# stdout as well!

Hope this helps!


flogrr
flogr@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top