Advertisement
Stewie410

Untitled

Nov 29th, 2021
1,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.39 KB | None | 0 0
  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}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement