Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
I fixed my question. I want to move the files instead of remove. I want a trash in command line. – Betterdev Nov 30 '11 at 23:22
Thanks for clearing that up. :) – iglvzx Nov 30 '11 at 23:23
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


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.