I created function using bash to retrieve EC2 SnapshotIds and output the list to a text file. I used a for loop:

```
for i in {0..20} ; do
  aws ec2 describe-snapshots \
    --filters Name=description,Values="*TestVolume$i*" \
    --query "reverse(sort_by(Snapshots, &StartTime))[0].SnapshotId" \
    >> GetSnapId
done

```

Above outputs the content but the output file has some blanks because of {0..20} where some line are empty. How can I loop to output unique SnapshotIds so that loop stops when all unique SnapshotIds are retrieved? Is using while loop better? What would you suggest?