I have a file named file.txt which contains data in the following format:
John
file
Abr
John
Tutu
I can read the file line by line using the following way:
#!/bin/sh
while read fl
do
echo $fl
done < file.txt
But I want to print a line with its following lines
I tried the script:
#!/bin/sh
prev=""
while read fl; do
prev="$fl"
done < file.txt
But this script does the things with consecutive lines only. please suggest some better solution.
Expected output:
John file
John Abr
John John
John Tutu
then
file Abr
file John
file Tutu
then
Abr John
Abr Tutu
then
John Tutu