Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / share / doc / gawk / examples / prog / | server ip : 104.21.89.46 your ip : 172.69.130.124 H O M E |
Filename | /usr/share/doc/gawk/examples/prog/tee.awk |
Size | 780 |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:55 |
Last modified | 29-Mar-2012 04:03 |
Last accessed | 08-Jul-2025 06:13 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
# tee.awk --- tee in awk
#
# Copy standard input to all named output files.
# Append content if -a option is supplied.
#
# Arnold Robbins, [email protected], Public Domain
# May 1993
# Revised December 1995
BEGIN \
{
for (i = 1; i < ARGC; i++)
copy[i] = ARGV[i]
if (ARGV[1] == "-a") {
append = 1
delete ARGV[1]
delete copy[1]
ARGC--
}
if (ARGC < 2) {
print "usage: tee [-a] file ..." > "/dev/stderr"
exit 1
}
ARGV[1] = "-"
ARGC = 2
}
{
# moving the if outside the loop makes it run faster
if (append)
for (i in copy)
print >> copy[i]
else
for (i in copy)
print > copy[i]
print
}
END \
{
for (i in copy)
close(copy[i])
}
#
# Copy standard input to all named output files.
# Append content if -a option is supplied.
#
# Arnold Robbins, [email protected], Public Domain
# May 1993
# Revised December 1995
BEGIN \
{
for (i = 1; i < ARGC; i++)
copy[i] = ARGV[i]
if (ARGV[1] == "-a") {
append = 1
delete ARGV[1]
delete copy[1]
ARGC--
}
if (ARGC < 2) {
print "usage: tee [-a] file ..." > "/dev/stderr"
exit 1
}
ARGV[1] = "-"
ARGC = 2
}
{
# moving the if outside the loop makes it run faster
if (append)
for (i in copy)
print >> copy[i]
else
for (i in copy)
print > copy[i]
}
END \
{
for (i in copy)
close(copy[i])
}