May 2000
Beginner
761 pages
18h 20m
English
When redirecting output from within awk to a UNIX file, the shell redirection operators are used. The filename must be enclosed in double quotes. When the > symbol is used, the file is opened and truncated. Once the file is opened, it remains opened until explicitly closed or the awk program terminates. Output from subsequent print statements to that file will be appended to the file.
The >> symbol is used to open the file, but does not clear it out; instead it simply appends to it.
% awk '$4 >= 70 {print $1, $2 > "passing_file" }' filename
|
Explanation
If the value of the fourth field is greater than or equal to 70, the first and second fields will be printed to the file ...
Read now
Unlock full access