Reputation: 53
I'm now using Ubuntu, and increasingly using terminal.
I would like to delete files from Trash via command line.
So, I've gotta delete files from ~/.local/share/Trash/files
dir.
All right, here's the question:
When I move some file to trash, it also creates a file_name.trashinfo
file in ~/.local/share/Trash/info
.
How could I automatically delete the corresponding .trashinfo
file when I delete something in ../files
?
Upvotes: 0
Views: 2406
Reputation: 1593
You can use the following script to delete both files simultaneously. Save it in some file in the ~/.local/share/Trash
directory, and call then bash <script.sh> <path-to-file-to-be-deleted-in-files-dir>
.
A sample call to delete the file test
if you named the script del.sh
: bash del.sh files/test
#!/bin/bash
file=$1
if [ -e "$file" ] # check if file exists
then
rm -rf "$file" # remove file
base=$(basename "$file")
rm -rf "info/$base.trashinfo" # remove second file in info/<file>.trashinfo
echo 'files deleted!'
fi
Upvotes: 1