aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cppawk.125
1 files changed, 25 insertions, 0 deletions
diff --git a/cppawk.1 b/cppawk.1
index 1f9589a..42902a6 100644
--- a/cppawk.1
+++ b/cppawk.1
@@ -104,6 +104,31 @@ Print the larger of field 1 or 2:
#define max(a, b) ((a) > (b) ? (a) : (b))
{ print max($1, $2) /* C comment */ } #awk comment'
+Implement awk-like processing loop within function, to process
+/proc/mounts:
+
+ #include "awkloop.h"
+
+ function main()
+ {
+ awkloop ("/proc/mounts") {
+ rule ($3 != "ext4") { nextrec }
+ rule ($2 == "/") { print $1 }
+ }
+ }
+
+ BEGIN {
+ main()
+ }
+
+Where
+.BI awkloop.h
+contains:
+
+ #define awkloop(file) for (; getline < file || (close(file) && 0); )
+ #define nextrec continue
+ #define rule(cond) if (cond)
+
.SH "SEE ALSO"
awk(1), cpp(6)
.SH BUGS