Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 1
    You will probably want to use a function instead of an alias. From info bash: "For almost every purpose, shell functions are preferred over aliases." Commented Jul 12, 2010 at 20:21
  • really? even for ones like ls -l or rm -i? Commented Jul 15, 2010 at 7:32
  • 6
    For almost every, not every. By the way, never do something like alias rm='rm -i'. One day, when you need it most, the alias won't be there and boom! something important will be lost. Commented Jul 16, 2010 at 9:02
  • wait, if you don't have the alias for rm -i, then you cannot count on having a shell script as well. So do you always type rm -i every time? Commented Aug 3, 2010 at 21:24
  • 11
    It's about habits. You could create an alias like the one in my previous comment and be in the habit of typing rm and expecting the -i behavior, then one day the alias is not there (for some reason it gets unset or not set or you're on a different system) and you type rm and it goes ahead immediately deleting stuff without confirmation. Oops! However, if you did an alias like alias askrm='rm -i' then you'd be OK, since you'd get a "command not found" error. Commented Aug 3, 2010 at 22:29