#!/bin/bash
i=0
d="$(date +%d)"
#wrong one:
#an="$(cal | awk '/[0-9]/ {print $2}' | tail -2)"
# fixed one:
an="$(cal | col -b | sed 's/_//g' | awk '/[0-9]/ {print $2}' | tail -2)"
for e in $an
do
if [ "$d" -eq "$e" ]; then
i=1
fi
done
echo i=$i
The problem is with $an/$e but i don't understand why and how to fix it. I've looked and it don't have any spaces, they are numbers however bash don't think this way.
<< EDIT >>
Ok i agree, maybe i've chosen the wrong way to do it, just thought that with cal it would be simple. Its part of a bigger script so i need to get a result from it so that script could proceed further down the code. I need to get 2 last mondays, tuesadays,..., or sundays and compare it with today, if the sate is the same give this info to the script.