Quantcast
Channel: How to read lines from a variable | bash - Unix & Linux Stack Exchange
Browsing latest articles
Browse All 4 View Live

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 Article



Answer 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 Article

Answer 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 Article

How 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
Browsing latest articles
Browse All 4 View Live


Latest Images