Command to get the total number of objects in an s3 bucket recursively:
aws s3 ls s3://bucketName/ --recursive --summarize | grep "Total Objects:"
Command to get the total number of objects in an s3 bucket within a particular folder(prefix) recursively:
aws s3 ls s3://bucketName/prefix/ --recursive --summarize | grep "Total Objects:"
Command to get the total number of objects in an s3 bucket within a particular folder(prefix)
aws s3 ls s3://bucketName/prefix/ | wc -l
aws s3api list-objects --bucket bucketName --output json --query "[length(Contents[])]"