Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

shell

shebang

awk

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 columns and chmod +x'd it. I want invoke it so that start and end 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!

like image 763
Ollie Saunders Avatar asked Sep 13 '09 17:09

Ollie Saunders


1 Answers

Try using:

#!/usr/bin/awk -f 

as an interpreter

like image 71
agsamek Avatar answered Oct 04 '22 12:10

agsamek