I am trying to parse data from a log file.
Here is the datafile in:
Data1
Data2
Data3
Data4
My code is as follow:
data=$(cat datafile)
echo "$data" | while read line; read line1;
do
echo "$line and $line1"
done
My desired output is:
Data1 and Data2
Data2 and Data3
Data3 and Data4
But instead I get:
Data1 and Data2
Data3 and Data4
I do understand why I get this behavior, however I am short on ideas about how to do as I want. Does anybody happen to know a trick?
Thanks