Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
I want to count all the lines that begin with a valid date. This code works if a line begins with a valid date but if it does not then it returns an error.
#!/bin/bash NOW=$( date +"%s" ) while read MONTH DAY TIME DATA do THEN=$( date -d "$MONTH $DAY $TIME" +"%s" ) COUNT=$((COUNT+1)) done < $1 echo $COUNT
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.