Note that there are some explanatory texts on larger screens.

plurals
  1. POerror in shell scripting?
    primarykey
    data
    text
    <p>I am trying a code in shell script. while I am trying to convert the code from batch script to shell script I am getting an error.</p> <p>BATCH FILE CODE </p> <pre><code>:: 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%"&gt;"%EC2_HOME%\Working\SnapshotsLatest_%date-today%.txt" </code></pre> <p>CODE IN SHELL SCRIPT</p> <pre><code>#Create a file with all latest snapshots FOR snapshot_date in $(' ec2-describe-snapshots | grep -i "SNAPSHOT" |sort /+64') do set "var=$snapshot_date" set "latestdate=$var:~0,10" ec2-describe-snapshots |grep -i "SNAPSHOT" |sort /+64 | grep "$latestdate"&gt;"$EC2_HOME%/SnapshotsLatest_$today_date" </code></pre> <p>I want to sort the snapshots according to dates and to save the snapshots that are created in latest date in a file.</p> <p>SAMPLE OUTPUT OF ece-describe-snapshots:</p> <pre><code>`SNAPSHOT snap-5e20 vol-f660 completed 2013-12-10T08:00:30+0000 100% 109030037527 10 2013-12-10: Daily Backup for i-2111 (VolID:vol-f9a0 InstID:i-2601)` </code></pre> <p>It will contain records like this</p> <p>the snaphsot latest file should cointain: </p> <pre><code>SNAPSHOT snap-cdd617f3 vol-f66409a0 completed 2013-12-04T09:24:50+0000 100% 109030037527 10 2013-12-04: Daily Backup for Sanjay_Test_Machine (VolID:vol-f66409a0 InstID:i-26048111) SNAPSHOT snap-c7d617f9 vol-3d335f6b completed 2013-12-04T09:24:54+0000 100% 109030037527 10 2013-12-04: Daily Backup for sachin_test_VPC (VolID:vol-3d335f6b InstID:i-e1c443d6) </code></pre> <p>Any suggestion or lead is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload