Corrections en anglais
This commit is contained in:
@@ -5,15 +5,15 @@
|
|||||||
# The output is saved to a text file with a sanitized name based on the bucket and directory.
|
# The output is saved to a text file with a sanitized name based on the bucket and directory.
|
||||||
|
|
||||||
# Example usage:
|
# Example usage:
|
||||||
# ./list-glacier-objects.sh my-bucket my-directory
|
# ./list-glacier-objects.sh my-bucket my-directory
|
||||||
# (Lists objects in the 'my-directory' directory within the 'my-bucket' bucket)
|
# (Lists objects in the 'my-directory' directory within the 'my-bucket' bucket)
|
||||||
# ./list-glacier-objects.sh my-bucket
|
# ./list-glacier-objects.sh my-bucket
|
||||||
# (Lists all objects in the 'my-bucket' bucket)
|
# (Lists all objects in the 'my-bucket' bucket)
|
||||||
|
|
||||||
# Check the number of arguments
|
# Check the number of arguments
|
||||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
||||||
echo "Usage: $0 <bucket_name> [directory_name]"
|
echo "Usage: $0 <bucket_name> [directory_name]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Retrieve the arguments
|
# Retrieve the arguments
|
||||||
@@ -22,16 +22,16 @@ DIRECTORY="$2"
|
|||||||
|
|
||||||
# Function to "sanitize" names for the output file
|
# Function to "sanitize" names for the output file
|
||||||
sanitize_name() {
|
sanitize_name() {
|
||||||
echo "$1" | tr -dc '[:alnum:]-_.'
|
echo "$1" | tr -dc '[:alnum:]-_.'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Construct the output file name
|
# Construct the output file name
|
||||||
SANITIZED_BUCKET=$(sanitize_name "$BUCKET")
|
SANITIZED_BUCKET=$(sanitize_name "$BUCKET")
|
||||||
if [[ -n "$DIRECTORY" ]]; then
|
if [[ -n "$DIRECTORY" ]]; then
|
||||||
SANITIZED_DIRECTORY=$(sanitize_name "$DIRECTORY")
|
SANITIZED_DIRECTORY=$(sanitize_name "$DIRECTORY")
|
||||||
OUTPUT_FILE="${SANITIZED_BUCKET}_${SANITIZED_DIRECTORY}_glacier-restore.txt"
|
OUTPUT_FILE="${SANITIZED_BUCKET}_${SANITIZED_DIRECTORY}_glacier-restore.txt"
|
||||||
else
|
else
|
||||||
OUTPUT_FILE="${SANITIZED_BUCKET}_glacier-restore.txt"
|
OUTPUT_FILE="${SANITIZED_BUCKET}_glacier-restore.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Construct the AWS CLI command
|
# Construct the AWS CLI command
|
||||||
@@ -39,7 +39,7 @@ COMMAND="aws s3api list-objects-v2 --bucket $BUCKET --query \"Contents[?StorageC
|
|||||||
|
|
||||||
# Add the prefix if a directory is specified
|
# Add the prefix if a directory is specified
|
||||||
if [[ -n "$DIRECTORY" ]]; then
|
if [[ -n "$DIRECTORY" ]]; then
|
||||||
COMMAND+=" --prefix $DIRECTORY"
|
COMMAND+=" --prefix $DIRECTORY"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Finalize the command with formatted output
|
# Finalize the command with formatted output
|
||||||
|
|||||||
Reference in New Issue
Block a user