REGEX at awk file

More complex awk text processing is better to put in the file. And there can be regex filter as well. Below is a simple example utilizing awk code in the file xml-info.awk, which prints information only for XML files.

$ ls -l
total 24
-rw-r--r-- 1 User User 9223 Jul 26 11:06 alpha.html
-rw-r--r-- 1 User User 6173 Jul 29 10:03 alpha.xml
-rw-r--r-- 1 User User 3227 Jul 29 10:43 beta.xml
BEGIN { print "Hello at BEGIN"}
 printf("filename: %s, size: %s\n", $9, $5);
END { print "Hello at END"}
$ ls -l | awk -f ../bin/xml-info.awk
Hello at BEGIN
filename: alpha.xml, size: 6173
filename: beta.xml, size: 3227
Hello at END
This entry was posted in Blogroll, workday. Bookmark the permalink.

Leave a Reply