I would like to create a bash script to choose from .ics files in a folder then do a 'find and replace' within that selected file, then save and rename that file. I have cobbled together some things from searches, but don't know enough about what I'm doing to make it all work...
Here is what I have for a menu:
#!/bin/bash echo "The following `*.ics` files were found; select one:" # set the prompt used by select, replacing "#?" PS3="Use number to select a file or 'stop' to cancel: " # allow the user to choose a file select filename in *.ics do # leave the loop if the user says 'stop' if [[ "$REPLY" == stop ]]; then break; fi # complain if no file was selected, and loop to ask again if [[ "$filename" == "" ]] then echo "'$REPLY' is not a valid number" continue fi # now we can use the selected file echo "$filename installed" # it'll ask for another unless we leave the loop break done
This is the code I currently use to edit the .ics files, but it changes ALL .ics files in the current directory:
#!/bin/bash ###Fixes all .ics files to give ALL DAY events rather than 0000-2359 ####All .ics files FILES="*.ics" # for loop read each file for f in $FILES do INF="$f" ##Change DTSTART:[yyyymmddThhmmss] to DTSTART;VALUE=DATE...## sed -i[org] 's/DTSTART:2016/DTSTART;VALUE=DATE:2016/g' $INF sed -i[org] 's/T[0-9][0-9][0-9][0-9][0-9][0-9]/ /g' $INF ###Remove DTEND:### sed -i[org] 's/DTEND:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/ /g'$INF done
How can I put this all together to achieve my goal??