Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    2

    Unanswered: output of the command $! , $_ and $$

    Hi,
    In Shell script, what will be the output of the command $! , $_ and $$ ?

    Thanks

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Quote Originally Posted by nitikamehta23
    Hi,
    In Shell script, what will be the output of the command $! , $_ and $$ ?

    Thanks
    They are not commands, they are special shell variables.
    • $! the process id of the last command run in the background.
    • $- the current options supplied to this invocation of the shell.
    • $_ Last argument of previous command
    • $$ the process number of this shell - useful for including in filenames, to make them unique.

    Use the echo command to see what they contain.

    Mike

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    I just would like to add something to $$: do not rely on a really unique file name using $$. For anything bordering on important things, additional checks will be needed.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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