print items > output-file $ awk '{ print $2 > "phone-list"
> print $1 > "name-list" }' BBS-list
$ cat phone-list
-| 555-5553
-| 555-3412
...
$ cat name-list
-| aardvark
-| alpo-net
...
Each output file contains one name or number per line.
print items >> output-file
Here is the example code:
cat > test.txt
a
b
c
d
awk 'BEGIN{print "e1" >> "test.txt"; print "e2" >> "test.txt"; print "e3" >> "test.txt";}'
$ cat test.txt
a
b
c
d
e1
e2
e3
awk 'BEGIN{print "e1" > "test.txt"; print "e2" > "test.txt"; print "e3" > "test.txt";}'
$ cat test.txt
e1
e2
e3
But I just don't understand why the test.txt is gone in code below:
awk 'BEGIN{print "e1" > "test.txt"; system("rm test.txt");print "e2" > "test.txt"; print "e3" > "test.txt";}'
No comments:
Post a Comment