我有一个批量脚本,其中包含代码
:: Create a file with all latest snapshots
FOR /F "tokens=5" %%a in (' ec2-describe-snapshots ^|find "SNAPSHOT" ^|sort /+64') do set "var=%%a"
set "latestdate=%var:~0,10%"
call ec2-describe-snapshots |find "SNAPSHOT"|sort /+64 |find "%latestdate%">"%EC2_HOME%WorkingSnapshotsLatest_%date-today%.txt"
我需要将批处理脚本转换为linuxshell脚本。我怎么能那样做。我需要获取在最近日期创建的所有最新快照的信息。类似于2013-12-10(日期格式)
感谢
您可以尝试:
#!/bin/bash
#
LATESTDATE=`ec2-describe-snapshots | grep "SNAPSHOT" | awk '{print $5}' | sort | cut -d "T" -f 1 | tail -1`
ec2-describe-snapshots | grep "SNAPSHOT" | grep ${LATESTDATE} > ~/SnapshotLatest_`date`.txt