How to read line by line and match text with next line?
Solution 1:
You can accomplish this with a simple for-loop
#!/bin/bash
mapfile -t < text.txt
for ((a=0,b=1; $b<${#MAPFILE[@]}; a++,b++)); do
[[ ${MAPFILE[$a]} = ${MAPFILE[$b]} ]] && echo ${MAPFILE[$a]}
done > unique.txt