I am unable to add timestamp to the output from AWS CLI in log file
I have tried through awk but its giving me error
aws s3 --output text sync localPath s3://bucketName --endpoint-url https://s3-vpcurl.com | awk '{ print strftime("[%Y-%m-%d %H:%M:%S]"), $0 }' >> C:\syncFromS3\NASToS3-Log.txt
awk: cmd. line:1: { print strftime([%Y-%m-%d
awk: cmd. line:1: ^ syntax error
I wanted to print the logs along with the timestamp in my log file.
for example:-
[2024-04-22 12:20:38] Completed 440 Bytes/949.5 KiB (382 Bytes/s) with 6 file(s) remaining
[2024-04-22 12:20:38] upload: ..\..\syncFromS3\result_90.csv to s3://s3BucketName/IndexFilesCSV/Results/result_90.csv
or is there any other way to do this?
Any help will be appreciated.
awk expects the format string for strftime
to be quoted
try
aws s3 --output text sync localPath s3://bucketName --endpoint-url https://s3-vpcurl.com | awk '{ print strftime("[%Y-%m-%d %H:%M:%S]"), $0 }' >> C:\\syncFromS3\\NASToS3-Log.txt
Make sure the redirection uses double backslashes as path separator on windows.