Ollie Saunders Ollie Saunders - 1 year ago 121
Bash Question

Invoking a script, which has an awk shebang, with parameters (vars)

I have an awk script that I have defined thus:

#!/usr/bin/env awk
BEGIN { if (!len) len = 1; end = start + len }
{ for (i = start; i < end; i++) { print $1 } }

I have saved it as
chmod +x
'd it. I want invoke it so that
are defined as it traverses over a file. I was thinking this should work:

cat some_file | columns -v start=2

But it doesn't. Help!

Answer Source

Try using:

#!/usr/bin/awk -f

as an interpreter

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download