https://github.com/gasinan/recycle-bin
Simple and Stupid Linux Bash Recycle Bin
https://github.com/gasinan/recycle-bin
bash linux recycle-bin
Last synced: 2 months ago
JSON representation
Simple and Stupid Linux Bash Recycle Bin
- Host: GitHub
- URL: https://github.com/gasinan/recycle-bin
- Owner: GasinAn
- License: other
- Created: 2024-11-09T07:02:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-02T08:07:37.000Z (over 1 year ago)
- Last Synced: 2025-06-17T11:09:05.159Z (about 1 year ago)
- Topics: bash, linux, recycle-bin
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# recycle-bin
Simple and Stupid Linux Bash Recycle Bin
```bash
del() {
while [ $# -gt 0 ]; do
oldpath=$(realpath -s "$1")
olddir=$(dirname "$oldpath")
oldname=$(basename "$oldpath")
newdir=~/.recycle_bin/$(date -I)
newname=$(date -Ins)-"$oldname"
mvbksh=$newdir/.mvbk."$newname".sh
mkdir -p $newdir
mv "$1" $newdir/"$newname"
mvbksh_lines=(
"#!/bin/bash"
""
"set -e"
""
"if [ -e '$olddir/$oldname' ]; then"
" echo '\"$olddir/$oldname\" exists!'"
" echo 'Fail to move back.'"
" exit 1"
"fi"
""
"mkdir -p '$olddir'"
"mv '$newdir/$newname' '$olddir/$oldname'"
"rm '$mvbksh'"
)
printf "%s\n" "${mvbksh_lines[@]}" > "$mvbksh"
chmod u+x "$mvbksh"
shift
done
}
```
## License
[GLWT(Good Luck With That) Public License](https://github.com/GasinAn/recycle-bin/blob/main/LICENSE)