I has many file need to add a $var in txt file , I don't know how to do
#get file name
filename=`find . -not -name '*Err*' -name *202210*.txt`
#get file date
filedate=`find . -not -name '*Err*' -name *202210* | awk -F _ '{print $2,$3}' | awk -F . '{print $1}'
#add file date in txt file
for i in $filedate
do
sed "s/^/$filedate /" $filename
done
but I got a error message "bad option in substitution expression"
and I try to see this quest, but I don't know how to fix this problem. Using different delimiters in sed commands and range addresses