X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=upload_ics;h=ce96a8f4b3ba381405bb5197017fa93d60c4158f;hb=59404941343ff9bb75baf172c153f572bd1e4f4c;hp=559d442c273a81ab68387ccf3ba4740362734d36;hpb=799dd7bdd11086efbaf7e6c5e0c9abf37fa39267;p=bin.git diff --git a/upload_ics b/upload_ics old mode 100644 new mode 100755 index 559d442..ce96a8f --- a/upload_ics +++ b/upload_ics @@ -8,20 +8,20 @@ tempdir=$(mktemp -d) tempdir=$(readlink -f "$tempdir") trap "/bin/rm -f \"$tempdir\"/*.ics; rmdir \"$tempdir\"" QUIT INT EXIT -for ics in "$@"; do - bevents=($(grep -n BEGIN:VEVENT "$file" | cut -d: -f1)) - eevents=($(grep -n END:VEVENT "$file" | cut -d: -f1)) +for file in "$@"; do + bevents=($(grep -hn BEGIN:VEVENT "$file" | awk -F: '{print $1}')) + eevents=($(grep -hn END:VEVENT "$file" | awk -F: '{print $1}')) ehead=${bevents[0]} let "ehead -= 1" - bfoot=$(wc -l < $file) + bfoot=$(wc -l "$file") let "bfoot -= ${eevents[-1]}" for (( i=0; i < ${#bevents[@]}; i++)); do - head -n $ehead "$file" > "$file"-$i.ics - sed -n ${bevents[$i]},${eevents[$i]}p "$file" >> "$file"-$i.ics - tail -n $bfoot "$file" >> "$file"-$i.ics + head -n $ehead "$file" > "$file-$i.ics"; + sed -n ${bevents[$i]},${eevents[$i]}p "$file" >> "$file-$i.ics"; + tail -n $bfoot "$file" >> "$file-$i.ics"; done done