variable in awk
-v
でawk内でだけ使える変数を定義できる。応用技として、環境変数を突っ込むことも可能。
awk -F',' -v name="$variable" '{print name $1}'
あと思ったけど、cheat awk
の-v
の使い方微妙に変。
https://github.com/chrisallenlane/cheat/blob/master/cheat/cheatsheets/awk#L7-L8
variable in awk
-v
でawk内でだけ使える変数を定義できる。応用技として、環境変数を突っ込むことも可能。
awk -F',' -v name="$variable" '{print name $1}'
あと思ったけど、cheat awk
の-v
の使い方微妙に変。
https://github.com/chrisallenlane/cheat/blob/master/cheat/cheatsheets/awk#L7-L8