You are not logged in.

#1 2005-06-18 19:41:01

Todd_Z
Member
From: MA, USA
Registered: 2005-01-31
Posts: 35
Website

Alias with an argument?

I want to make an alias rmall for removing everything within a directory... I may be blatantly wrong, but i think the command for that is:

rm -d -R folder/* && rmdir folder

so i'd like to make an alias for rmall folder

Can i do this in the .bashrc file? or do I have to make an actual script?

Offline

#2 2005-06-18 19:56:49

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: Alias with an argument?

i've never heard of it,

i don't think you need a script for it really, just run "rm -r folder" ,that should fix it,


arch + gentoo + initng + python = enlisy

Offline

#3 2005-06-18 20:12:17

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Alias with an argument?

Here's how to do alias defititions, from my .bashrc:

  alias ls='ls --color'
  alias lsa='ls --color --all'
  alias reboot='sudo /sbin/reboot'
  alias halt='sudo /sbin/halt'
  alias pacman='sudo /usr/bin/pacman'
  alias jedit='jedit -reuseview'
  alias cdb='cd $(cat $HOME/.currentbuffer)'
  alias rmpkg='rm -r filelist src/ pkg/ *.pkg.tar.gz'

And here's one way to do multiple commands, also in my .bashrc:

  function cvsrm() {
      rm $1
      cvs remove $1
  }
  
  function tarpkg() {
      name=`basename $1`
      tar cf $name.tar $1
      gzip $name.tar
  }

But yes, rm -r will remove a directory and all its contents for you.

Dusty

Offline

#4 2005-06-18 22:46:17

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: Alias with an argument?

if you want to use arguments for other stuff you should do as dusty shows with his functions examples,


arch + gentoo + initng + python = enlisy

Offline

#5 2005-06-19 01:37:56

Todd_Z
Member
From: MA, USA
Registered: 2005-01-31
Posts: 35
Website

Re: Alias with an argument?

great, thanks - btw where is the sudo file so that i can add my account to that list?

Offline

#6 2005-06-19 01:58:54

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Alias with an argument?

just run "visudo"

Offline

#7 2005-06-19 06:55:59

IceRAM
Member
From: Bucharest, Romania
Registered: 2004-03-04
Posts: 772
Website

Re: Alias with an argument?

removing a dir and its contents can be done with

rm -rf dirname

Be careful! Don't try "rm -rf /" !

Offline

#8 2005-06-19 13:56:45

Todd_Z
Member
From: MA, USA
Registered: 2005-01-31
Posts: 35
Website

Re: Alias with an argument?

When I run Visudo, would it be a bad idea to grant myself all permissions?

Offline

#9 2005-06-19 14:06:27

klapmuetz
Member
From: Germany
Registered: 2005-03-19
Posts: 75

Re: Alias with an argument?

Of course it would.


Hello girls, I like rock climbing, mountain biking and rafting! Write me!

Offline

#10 2005-06-19 15:54:07

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Alias with an argument?

Todd_Z, you may want to start reading some man pages and searching google a little before posting here. This is the Newbie Corner, and all questions are welcome, but work with Linux often requires an ability to research difficult questions. It helps to gain experience with easier questions than to get thrown into it when nobody has an answer.

http://www.catb.org/~esr/faqs/smart-que … tml#before

Dusty

Offline

#11 2005-06-19 18:17:05

Todd_Z
Member
From: MA, USA
Registered: 2005-01-31
Posts: 35
Website

Re: Alias with an argument?

sowwy  sad <hangs head in shame>

Offline

#12 2005-06-19 20:48:22

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Alias with an argument?

Lol, its not serious. Newbie corner is a great place to post any sort of question. I was just suggesting research as an alternative to asking questions. You'll also find that its quicker in a lot of cases. ;-)

Dusty

Offline

#13 2005-06-19 23:02:55

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Alias with an argument?

You're also much more likely to remember something if you work it out yourself.

Offline

#14 2005-06-19 23:40:34

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Alias with an argument?

tomk wrote:

You're also much more likely to remember something if you work it out yourself.

I couldn't agree more - also, you tend to remember sites for reference and it helps improve search skills (which is a big deal, IMHO)

Offline

Board footer

Powered by FluxBB