Answer the question
In order to leave comments, you need to log in
How to split console output into lines in Shell?
Hello!
The question is as follows. I have a Shell script, inside of which grep is done by files in the directory, I need to put the output of grep into a variable line by line. If I do something like this:
qqq=`grep nIHR 'PATTERN' file`
for q in qqq
do
echo $q
done
Answer the question
In order to leave comments, you need to log in
Use IFS:
qqq=`grep -nIHR 'offset' ./file.dat`
IFS='
'
for q in $qqq
do
echo $q
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question