I have a file hotfix_final
that looks like this:
https://download.abc.com 06/24/2019
https://download.abc.com 06/26/2019
https://download.abc.com 07/05/2019
I need to write a shell script that reads the file line by line and then takes the date that is next to the link into a variable so that I can compare it to the current date. If the dates are equal and usage_type = 4
, I need the script to wget the link.
What I tried so far:
usage_type=$( cat /opt/abc/ps/usage.txt )
current_date=$( date +%x )
lines=$( wc -l /home/abc/hotfix_final | awk '{print $1}' )
count=0
while $count <= $lines; do
hf_link=$( awk if( NR=$count ) '{print $1}' hotfix_final )
relase_date=$( awk if( NR=$count ) '{print $2}' hotfix_final )
count=$(( count+1 ))
done < hotfix_final
In the above example, I used:
$lines
to show the max number of lines to read.$hf_link
to get the link$release_date
to get the date next to $hf_link
Now, I am not sure how to write the part that checks whether $usage_type == 4
and $current_date = $relase_date
are true, and if so, wget the link. This needs to be done individually for each line of the file.