How to awk or grep a variable, without using echo?
awk, bash, grep, performance
Solution
In bash you can redirect from a variable to stdin using the one-line heredoc:
awk "/test/ {for(i=1; i<=100; i++) {getline; print}}" <<< "$var"
Problem
I'm working with large variables and to speedup my script I'd like to `awk` or `grep` a variable without using `echo/printf` what I've tried: ``` awk "/test/ {for(i=1; i<=100; i++) {getline; print}}" "$var" awk: fatal: cannot open file `<<$var content>>' for reading (No such file or directory) grep -A 100 test "$var" grep: `<<$var content>>': No such file or directory ```