[QUESTION] How to use standard in twice (Entry Nr. 128, by user 1 | edit) |
|
|
in a shell scrpt:
CONDITION=$1 DATA=$(grep $CONDITION - | sed 's/^([a-z]*).*/$1/')
gets the first lowercase word from all lines of standad in that match condition
What do we do if in a second step we want to get all lines from standard in that contain $DATA?
for WORD in $DATA do grep WORD - done
does not work as standard in (-) is empty after we extracted the words with the first grep.
Storing it in a variable or temp file is both possible but not preferred as you do not know how much data will come from standard in |
|
|
Create a new entry at this position
|
|
|