i have a file that looks like this, but a lot bigger :
xxxxxxx xxxxx xxxx
yyyyyyy yyyyy yyyy
zzzzzzz zzzzz zzzz
bbbbbbb bbbb
but a lot bigger, i want to compare the second and the third column, only the first 4 digits do i wrote something like this :
while IFS='' read -r line; do
a=${line:181:4}
b=${line:276:4}
str1="$a"
str2="$b"
# echo $a
# echo $b
# echo $str1
# echo $str2
if [[ "$str1" == "$str2" ]]
then
echo $line >> $1.diffs.txt
fi
done <$1
the reason for the str* is because the numbers occasionally start with 0 so it interprets them as octal and gives me an error, my problem is that the output on the $1.diffs.txt contains only 1 white space, instead of all of them. IE
Output :
xxxxxxx xxxxx xxxx
yyyyyyy yyyyy yyyy
zzzzzzz zzzzz zzzz