Hi,
My command is getting stuck while running it.
observed that the grep command doesn't returned any data ($? was 1) and it failed.
This command is assigned into the variable and used in other command as script progresses. To continue the script output, i have to press ^C twice and script continues for the loop.
Break didn't worked on this and have to press ^C twice.
full code
pdate=` { date +%Y%m%d; for d in Mon Tue Wed Thu Fri; do date +%Y%m%d -d "last $d"; done; } | sort | tail -5`
for d in $pdate;
do
filename=`grep $i /home/lim/updates/logs/log*$d* | cut -d ':' -f1 | uniq`;
updatefile=$(awk -v var=$i '1; $0 ~ var {exit}' $filename | awk '/upd_/ {a=$0} END{print a}' | cut -d ' ' -f3);
completiontime=( $(grep $updatefile /home/lim/config/load_updates.hst | grep "Unpack complete" | cut -d " " -f5-7) );
echo "$(tput sgr 0) Processing_date - $(tput setaf 2) $d $(tput sgr 0) UpdatePackage - $(tput setaf 6) $updatefile $(tput sgr 0) Processing_Time $(tput setaf 3)${completiontime[@]:0} $(tput sgr 0)" ;
done;
filename=`grep $i /home/lim/updates/logs/log*$d* | cut -d ':' -f1 | uniq`; updatefile=$(awk -v var=$i '1; $0 ~ var {exit}' $filename | awk '/upd_/ {a=$0} END{print a}' | cut -d ' ' -f3 );
completiontime=( $(grep $updatefile /home/lim/config/load_updates.hst | grep "Unpack complete" | cut -d " " -f5-7 ) )
Command failed and $? = 1
grep $i /home/lim/updates/logs/log*$d* | cut -d ':' -f1 | uniq
tried workaround to get always true before passing in if condition
grep $i /home/lim/updates/logs/log*$d* | cut -d ':' -f1 | uniq || true
if code i tried
---------- Post updated 10-24-16 at 01:46 AM ---------- Previous update was 10-23-16 at 10:31 PM ----------
The below code worked as of now:)
if [[ ! -f `grep $i /home/lim/updates/logs/log*$d* | cut -d ':' -f1 | uniq` ]]; then
echo "File is missing for $d ";
break;
else
stmt;
fi