I want to write the result of grep inside for loop into a file, keeping original file structure. Original file:
$cat newtest1
some_text
/homes/myself/joz
ivan petrov - 20/10/19
new customer:
/homes/myself/silvia
john smith - 30/11/19
old customer:
some_text
I am using grep in for loop and getting the following:
$for i in `cat newtest1 | grep customer -B2`; do echo $i; done
/homes/myself/joz
ivan
petrov
-
etc. File's structure got changed. I tried printf - the same result. Question: how to keep file's structure using grep in for loop?
for
loop? Why not just thegrep
?