# Convert date to quarter date_quarter() { local date=$1 local year=$(date -d "$date" +%Y) local month=$(date -d "$date" +%m) month=${month#0} # Remove leading zero from month local quarter=$((($month - 1) / 3 + 1)) local quarter_format="${year}Q${quarter}" echo "$quarter_format" } # Example usage: input_date="2023-09-02" result=$(date_quarter "$input_date") echo "Quarter format: $result" # "2023Q3"