我无法将时间戳添加到日志文件中 AWS CLI 的输出
我已经尝试通过 awk 但它给了我错误
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
我想打印日志以及日志文件中的时间戳。
例如:-
[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
或者还有其他方法可以做到这一点吗?
任何帮助将不胜感激。
awk 期望
strftime
的格式字符串被引用
尝试
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
确保重定向在 Windows 上使用双反斜杠作为路径分隔符。