Issue
I am running a Docker Alpine based image which has bash installed.
bash --version
GNU bash, version 4.3.48(1)-release (x86_64-alpine-linux-musl)
In the following command, i am trying to convert first letter of month to lowercase but it's not working:
find ../ -type f -name "*.md" \
-exec bash -c '
f=${1#./}
gzip -9 "$f"
mv "$f".gz "$f"
aws s3 cp "$f" s3://bucket_name/ --metadata time=$(date +%d-%b-%Y.%H%M | sed '\''s#\([A-Z]\)#\L\1#'\'') ' _ {} \;
The date attribute it assigns to the file(s) is:
"Metadata": {
"timestamp": "10-LSep-2018.1054"
}
\L
is not working in this case. The expected date should have been "10-sep-2018.1054"
How can i get it working with the bash version present in Docker image?
Solution
As it turns out OP only has access to a minimal version of sed
that does not recognize the \L replacement command and for his use case de-capitalizing ALL letters in the output is acceptable.
The most straightforward way to achieve this is with the command
tr [:upper:] [:lower:]
Answered By - Sam Answer Checked By - Robin (WPSolving Admin)