Quantcast
Channel: How to read lines from a variable | bash - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 4

How to read lines from a variable | bash

0
0

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 like so :

INPUT_file=$(grep -E 'INPUT.*ACCEPT' $FILE)

and then assign that result to the variable INPUT_file

I would like to now read lines from the variable "INPUT_file" but when I try to include in the while loop:

while read line; do
....
done < $INPUT_file

I get the following error:

$INPUT_file: ambiguous redirect

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images