I have a file, list.txt that contains:
234
243
324
342
423
432
How can I find if reverse patterns (i.e., 432 is the reverse pattern of 234) exists and remove the reverse pattern? I have attempted
while IFS= read -r line; do
reverse=$(echo $line|rev)
if grep -q $reverse list.txt; then
sed -i "s/$reverse//g" list.txt
else :
fi
done < list.txt
but this removes every line from list.txt. My expected output would be
234
243
324
Is what I want to accomplish possible? My MWE is a short list, but this list can (and will) grow considerably. Thanks in advance.