Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- log="rmfilelog"
- sl="slfile"
- trap 'unset log sl choice' EXIT
- read -i "n" -n 1 -rp "Delete file: '${sl}' [y/N]: " choice
- if [[ "${choice,,}" == "y" ]]; then
- printf '%s\n' "Removed file: '${sl}'"
- rm --verbose "${sl}" &> "${log}"
- else
- printf '%s\n' "Copied File: '${sl}' -> '${log}'"
- cp "${sl}" "${log}"
- fi
- printf '%s\n' "Contents of log: '${log}'"
- cat "${log}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement