Skip to content

Instantly share code, notes, and snippets.

@nuxlli
Created July 15, 2020 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuxlli/3fe302567917bd9671a7419349da4efc to your computer and use it in GitHub Desktop.
Save nuxlli/3fe302567917bd9671a7419349da4efc to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
bucket_path=$1
bucket_bk_path="$1_$(date +%s)"
tmp_file=$(mktemp)
# Donwload a temporary file
aws s3 cp "${bucket_path}" "${tmp_file}"
trap "{ rm -f \"$tmp_file\"; }" EXIT
# Edit
vim "${tmp_file}"
# Backup file before replace
aws s3 cp "${bucket_path}" "${bucket_bk_path}"
# Replace file
aws s3 cp "${tmp_file}" "${bucket_path}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment