|
All the examples assume that the following aliases exist: rm="trsh.pl"
undo="trsh.pl -u" Removal:rm test1 test2 *.gz # Move a bunch of files to trash. Directories are not deleted by default. trsh will give an error message. Use the -r option. Refer being recursive below. Recover:undo test1 # Specify the file name to recover
undo "*.gz" # Specify a regex in quotes.
undo # Recover the latest file which was deleted. Displaysrm -l
(1) test1
(1) test2
(3) test The first column displays the number of files which exist in the trash with the same name. Here the file "test" exist 3 times in the trash. This also displays one of the features of trsh. If a file is deleted, and another file already exists in the trash with the same name, that file is NOT overwritten and this is handled internally. rm -s
1024 Display the size in kilobytes. If you want an output to be more human readable, use the -h option. rm -sh
1 MB Size of each file can also be displayed with the listing, and that too can be human readable. rm -lsh
Total Trash Size: 1MB
(1) test1 224 KB
(1) test2 200 KB
(3) test 600 KB Here total size of each file is displayed in the listing. Now as 3 different version of the file "test" exist in the trash, the sum of all their sizes is 600 KB (Not the size of each of them). Emptyingrm -e test # Remove test from the trash permanently.
rm -e "test*" # Remove test1 test2 (Which match the regex "test*" from the trash permanently
Are you sure you want to remove test1 from the trash? (y/n):y
Are you sure you want to remove test2 from the trash? (y/n):y
rm -e # Empty the trash.
Are you sure you want to empty the trash? (y/n):y You can be forceful with the empty option, where trsh will not nag you. but it is not recomended! rm -ef "test*" # Do not ask for every file.
rm -ef # Do not ask for a confirmation Being Forcefulrm -f test Removes the file test permanently bypassing the trash. In simpler words, test is gone and cannot be recovered! In simple words, when deleting files, the -f option mimics rm and hence all the options you use is passed on to rm except the force flag. So, if you do want to pass the force flag (To avoid rm from nagging you) you can pass another -f option which instructs trsh to pass the -f flag onto rm: rm -rff new_test_dir some_files_*
# same as:
/bin/rm -rf new_test_dir some_files_* Being Recursiverm -r test_dir # Move test_dir to the trash
rm -rf new_test_dir # Remove new_test_dir permanently. while test_dir is moved to trash, new_test_dir is permanently removed. Use the -r option to delete directories. OthersUse the -v option to make anything verbose. --help option displays the help and the version. One use of the -x optionHere I provide the use of the -x option. Hopefully its purpose will be clear in this example. rm test1 test2 "test*" # test* is actually a file name
undo "test*" Here the result will be that "test*" is NOT used as a regex as such a file exists in the trash. This is trsh's default behavior. And hence only the file "test*" is recovered. undo -x "test*" This on the other hand, will force the use of regex and hence "test1", "test2" and "test*" is recovered. Perl Style RegexYou can use the perl style of regular expressions to delete, restore and remove files from trash. The -p|--perl-regex option turns this feature on. rm -p "/some/random/path/test\.\d+\.log" # Removes all files test.<number>.log from /some/random/path
undo -p "test\.\d+\.log" # Recovers all files with the name test.<number>.log to cwd.
rm -ep "test\.\d+\.log" # Removes all test.<number>.log from the trash. This option allows you to use trsh in a more advanced way if you are comfortable with perl regular expressions. As usual, you need to enclose the regex in quotes.
|