Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Following the suggestion by bathory, you may want to be able to move more files at once (for example when using wildcards). In this case better to use $@ to catch all the command line arguments:
Code:
mv "$@" ~/.Trash
Moreover, since emptying trash is something that many users forget about, you may want to add a check on the Trash size and/or on the filesystem percent usage. Eventually the user may be warned and receive advice to empty the trash bin. Finally, take in mind that files with the same name will be overwritten, so that older versions will be definitively lost.
Sometimes that's not a good idea though since there are some system scripts like boot scripts that may also use the rm command to permanently delete files like temporary files. It's probably better to create another similar script utility with different filename like /usr/bin/trash.
Sometimes that's not a good idea though since there are some system scripts like boot scripts that may also use the rm command to permanently delete files like temporary files. It's probably better to create another similar script utility with different filename like /usr/bin/trash.
Agreed, I would not change the behaviour of a fundamental command like rm in such a way. Creating a new 'trash' command would be better.
Sometimes that's not a good idea though since there are some system scripts like boot scripts that may also use the rm command to permanently delete files like temporary files. It's probably better to create another similar script utility with different filename like /usr/bin/trash.
Sure, but putting an alias in his .bash_profile does not affect how rm works in boot scripts and system scripts in general.
Sure, but putting an alias in his .bash_profile does not affect how rm works in boot scripts and system scripts in general.
Well how bout the other scripts that will run after .bash_profile is loaded? e.g. co-shellscripts run by user apps?
Also I suggest that it's better to have functions instead of aliases since sometimes aliases do not work the way they should be. Perhaps at least on the earlier versions of bash?
Edit: Oh I forgot. Yeah right. Functions and aliases are not exported so this can be safely done.
Last edited by konsolebox; 06-22-2010 at 11:35 PM.
Well how bout the other scripts that will run after .bash_profile is loaded? e.g. co-shellscripts run by user apps?
Also I suggest that it's better to have functions instead of aliases since sometimes aliases do not work the way they should be. Perhaps at least on the earlier versions of bash?
Edit: Oh I forgot. Yeah right. Functions and aliases are not exported so this can be safely done.
Not only that, but .bash_profile is not executed by scripts run by user apps. This is the difference between .bash_profile and .barhrc. .bash_profile is only executed in interactive mode.
Not only that, but .bash_profile is not executed by scripts run by user apps. This is the difference between .bash_profile and .barhrc. .bash_profile is only executed in interactive mode.
No I did not meant that scripts will call .bash_profile, what I meant is what will be in the shell environment and shared to subscripts after it is called;.. but it's ok since it won't be exported or shared anyway.
Edit: Or maybe you meant a different angle.. well ok.
Actually we don't even have to think about it since sometimes .bashrc is not also called. What really mattered was the effect after a new virtual version of rm is created.
Last edited by konsolebox; 06-23-2010 at 12:53 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.