Quantcast
Channel: How to assign an input parameter for a function including awk? - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2

Answer by steeldriver for How to assign an input parameter for a function including awk?

$
0
0

Awkk's -v argument takes a name=value pair, allowing you to use name as a variable inside your awk program. So

tt() { r=$(j | awk -v id="$2" 'FNR=id && NR {print $1}'); jj $r; }

(TBH I'm not sure why the && NR is necessary here, or why you're distinguishing between NR and FNR when you are only passing a single input (stdin) to awk.)


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>