I have this function, I'm trying to add "MM" at the end of the line in case the line doesn't contain "MM" and it print it at the start of the line all the time..
recursiveFindReq `pwd`/allReqTemp.txt
while read line; do
if [[ $line != *MM* ]]; then
echo $line MM >> temp2
else
echo $line >> temp2
fi
done < allReqTemp.txt
here's the OUTPUT FOR CODE ABOVE
for example: for the input :
07/2018 08:00 09/07/2018 08:01 09:00 150
I expect :
07/2018 08:00 09/07/2018 08:01 09:00 150 MM
but I get :
" MM07/2018 08:00 09/07/2018 08:01 09:00 150"
as you can see in pics
succeed! took me just 2 hours
while read -a line; do
if [[ ${line[*]} != *MM* ]]; then
line[6]=MM
echo ${line[0]} ${line[1]} ${line[2]} ${line[3]} ${line[4]} ${line[5]} ${line[6]} >> temp2
else
echo ${line[*]} >> temp2
fi
done < allReqTemp.txt