I have text a file with a list of s3 objects, in the form of:
prefix_x/prefix_y/file_name_1
prefix_w/prefix_z/file_name_88
etc...
I wrote a bash script to delete all of these objects, as follows:
#! /bin/bash
LIST_OF_PATHS=$1
while read FILE_PATH; do
aws s3 rm s3://bucket-name/$FILE_PATH
done < $LIST_OF_PATHS
The script doesn't seem to delete the objects (they appear in the UI and in the terminal when ls
ing them with the CLI).
Further details and things I've already tried:
- deleting the objects manually with similar command in the CLI - it works.
- adding
ls
command to the loop provides no output, whereas typing this command manually on the very same files does give output. - adding sleep 0.1 to each iteration of the loop didn't help either.
- of course the script runs - I see the output:
delete: s3://bucket-name/prefix_x/prefix_y/file_name_1
, but the file doesn't actually get deleted. - running a simpler bash script with the same command and a specific file name (not inside a loop) does delete successfully.
What might be the problem?