#!/bin/sh
# get_level_2a_file_dates.sh

# A remote directory must be specified
if [ $# -eq 0 ]; then
    echo "get_level_2a_file_dates.sh: No remote directory specified"
    exit -1
fi

# Get a list of the orbital images in the directory
first_result=`ls "$1" | grep cips_raa_2a_orbit_ | grep -v thumb`
second_result=`echo "${first_result}" | wc -l`
# If there is nothing there the return value is "1"
if [ "${second_result}" -eq "1" ]; then
  exit 1
fi

# Pick out the date: the sixth field when splitting on underscore
# Sort the result and send back the list of unique dates
echo "${first_result/ /\n/}"| awk -F "_" '{print $6}' | sort | uniq

exit 0
