Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've tried to alias rm with rm='mv $1 /tmp/' to no avail.

How can I temporary delete files with the command line?

I want to replace the rm command with the mv command to not delete my files and create a trash with the command line like I'm using the trash icon on my desktop.

share|improve this question
    
"Temporarily delete" is an oxymoron. Can you explain what you want to do? –  iglvzx Nov 30 '11 at 23:21
1  
I fixed my question. I want to move the files instead of remove. I want a trash in command line. –  Phpdna Nov 30 '11 at 23:22
    
Thanks for clearing that up. :) –  iglvzx Nov 30 '11 at 23:23

1 Answer 1

up vote 3 down vote accepted

I think your question is answered here. In summary;

  • Adding an alias for rm is bad form, as other scripts (and/or users) on your system rely on the default behaviour
  • When you switch to another machine you'll use rm with wild abandon
  • Instead create an alias for your own command, such as del

To do this;

alias del 'mv -i $1 /tmp'

The -i flag warns you if a file of the same name already exists in trash, so you don't lose existing trashed files.

And you'll want that alias to be initiated whenever you open a shell, which depending on your system might be putting the command in ~/.bashrc

Some people reported that $1 doesn't work, and there's a suggested script in that thread I linked to which should help if that's the case.

Hope that helps

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.