Stewie410

Untitled

Nov 29th, 2021
871
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2.  
  3. log="rmfilelog"
  4. sl="slfile"
  5. trap 'unset log sl choice' EXIT
  6.  
  7. read -i "n" -n 1 -rp "Delete file: '${sl}' [y/N]: " choice
  8. if [[ "${choice,,}" == "y" ]]; then
  9.     printf '%s\n' "Removed file: '${sl}'"
  10.     rm --verbose "${sl}" &> "${log}"
  11. else
  12.     printf '%s\n' "Copied File: '${sl}' -> '${log}'"
  13.     cp "${sl}" "${log}"
  14. fi
  15.  
  16. printf '%s\n' "Contents of log: '${log}'"
  17. cat "${log}"
RAW Paste Data