in case the content of the file has the date of yesterday within the lines containing pattern AB this should be replaced by the current date. But if I use "sed", it will replace all the occurrences and I want to leave the first line as it is.
#! /bin/bash
while read line
do
if [[ $line =~ "AB" ]]
then
line=${line/$(date -d "-1 day" +%Y%m%d)/$(date +%Y%m%d)}
echo $line
else
echo $line
fi
done < file
OR
sed "/AB/ s/$(date -d "-1 day" +%Y%m%d)/$(date +%Y%m%d)/" file