Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not aware of a way to make a self-contained binary using AWK. However, if you like AWK, chances seem good that you might like Python, and there are several ways to make a self-contained Python program. For example, <a href="http://www.py2exe.org/" rel="nofollow noreferrer">Py2Exe</a>.</p> <p>Here's a quick example of Python:</p> <pre><code># comments are introduced by '#', same as AWK import re # make regular expressions available import sys # system stuff like args or stdin # read from specified file, else read standard input if len(sys.argv) == 2: f = open(sys.argv[1]) else: f = sys.stdin # Compile some regular expressions to use later. # You don't have to pre-compile, but it's more efficient. pat0 = re.compile("regexp_pattern_goes_here") pat1 = re.compile("some_other_regexp_here") # for loop to read input lines. # This assumes you want normal line separation. # If you want lines split on some other character, you would # have to split the input yourself (which isn't hard). # I can't remember ever changing the line separator in my AWK code... for line in f: FS = None # default: split on whitespace # change FS to some other string to change field sep words = line.split(FS) if pat0.search(line): # handle the pat0 match case elif pat1.search(line): # handle the pat1 match case elif words[0].lower() == "the": # handle the case where the first word is "the" else: for word in words: # do something with words </code></pre> <p>Not the same as AWK, but easy to learn, and actually more powerful than AWK (the language has more features and there are many "modules" to import and use). Python doesn't have anything implicit like the</p> <pre><code>/pattern_goes_here/ { # code goes here } </code></pre> <p>feature in AWK, but you can simply have an if/elif/elif/else chain with patterns to match.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload