Find the answer to your Linux question:
Results 1 to 3 of 3
What will this command do? rm -fr $@; Force remove recursively what?...
  1. #1
    Linux Newbie AboveNBeyond's Avatar
    Join Date
    Mar 2007
    Posts
    120

    Question rm -fr $@;

    What will this command do?
    rm -fr $@;
    Force remove recursively what?

  2. #2
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    Quote Originally Posted by AboveNBeyond View Post
    What will this command do? Force remove recursively what?
    In most shells, $@ represents the set of all parameters. So, if you wrote a script consisting of a single line with your command and you called it with:
    Code:
    ./myscript /home/AboveNBeyond /etc /usr/bin
    It would be equivalent to:
    Code:
    rm -fr /home/AboveNBeyond /etc /usr/bin
    Probably not a good idea. Of course, the command would only execute with the permissions it is run with so if you run that as normal user, AboveNBeyond, you would likely only delete your home directory as you don't have write permissions outside of ~.

    Maybe one of the shell scripting gurus can explain it better.

  3. #3
    Linux Newbie AboveNBeyond's Avatar
    Join Date
    Mar 2007
    Posts
    120
    AHH ok, point taken... I had it in my ~/.bashrc from some time back and could not remember why...
    alias rmd= "rm -fr $@;"

    So if I was in my home dir and hit rmd it would be a bad day. lol

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...