On Fri, 06 Aug 2004 18:57:08 -0500 (CDT), [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > How come the following script deletes itself? > > #!/bin/rm
Right there is your answer... I think you already knew this, and were posing a riddle, but for those who don't know... The character sequence "#!" at the beginning of a file, commonly known as the "she-bang", indicates that the rest of the line is the location of the file to use when executing this script. Common she-bangs are: #!/usr/bin/perl #!/usr/bin/less #!/bin/sh The last line is the default guess most shells will make when the she-bang is not present. Now, what the shell does when it sees the she-bang is, in essence[1], execute the command of the she-bang with the file to be executed as the first argument. So, when using a she-bang of "#!/bin/rm", the file is "executed" by supplying itself as the first argument to /bin/rm -- buhbye file. And nothing else in the file happens since, of course, rm doesn't even look at what's in the file in order to "execute" the file. Jacob Fugal [1] I'm sure there's probably a bit more to it behind the scenes, but for a high level view, the description above is sufficient. Plus, I have no idea what actually happens behind the scenes :) ____________________ BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________ List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
