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
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.