- 论坛徽章:
- 2
|
回复 3# 251995427
print items > output-file
This type of redirection prints the items onto the output file output-file. The file name output-file can be any expression. Its value is changed to a string and then used as a file name (see section Actions: Expressions).
When this type of redirection is used, the output-file is erased before the first output is written to it. Subsequent writes do not erase output-file, but append to it. If output-file does not exist, then it is created.
For example, here is how one awk program can write a list of BBS names to a file `name-list' and a list of phone numbers to a file `phone-list'. Each output file contains one name or number per line.
awk '{ print $2 > "phone-list"
print $1 > "name-list" }' BBS-list
print items >> output-file
This type of redirection prints the items onto the output file output-file. The difference between this and the single-`>' redirection is that the old contents (if any) of output-file are not erased. Instead, the awk output is appended to the file. |
|