↧
Answer by Valentin Bajrami for How to read lines from a variable | bash
You shouldn't invoke grep in this case. All can be done using your shell only. E.g while read -r line; do [[ $line =~ INPUT.*ACCEPT ]] && printf '%s\n' "$line"; done < your_iptables_file
View ArticleAnswer by Michael Homer for How to read lines from a variable | bash
You would be better off using process substitution rather than a variable: while read line; do .... done < <(grep -E 'INPUT.*ACCEPT' $FILE) (note two < characters). This avoids loading the...
View ArticleAnswer by David Dai for How to read lines from a variable | bash
That is when here string comes into play: while read line; do ... done<<<$INPUT_file
View ArticleHow to read lines from a variable | bash
I have a simple bash script that reads lines from a text file like so: #!/bin/bash FILE=$1 while read line; do ... done < $FILE which works fine but now I want to first parse the file using grep...
View Article