Thanks Robert.... That explained the problem. Best wishes
Joey On Sep 14, 8:27 am, Robert Citek <[email protected]> wrote: > The short answer: bash subshells. > > http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/... > > Here are a few more examples which may shed some light. > > $ echo $(pgrep bash) > 9430 > > $ echo $(exec pgrep bash) > 9430 > > $ echo -n ; pgrep bash > 9430 > > $ echo $(echo -n ; pgrep bash) > 9430 9568 > > $ echo $(echo $(echo -n ; pgrep bash)) > 9430 9574 9575 > > $ echo $(echo -n ; exec pgrep bash) > 9430 > > $ echo $BASH_SUBSHELL > 0 > > $ echo $(echo $BASH_SUBSHELL ) > 1 > > $ echo $(echo $(echo $BASH_SUBSHELL )) > 2 > > Regards, > - Robert > > On Sun, Sep 13, 2009 at 3:10 PM, Joey Wang <[email protected]> wrote: > > Dear all. > > > Here I got a question. > > see this BASH code: > > >> [j...@localhost ~]$ echo $(echo $(echo $(echo $(pgrep bash)))) > >> 4840 6508 6509 6510 6511 > >> [j...@localhost ~]$ echo $(echo $(echo $(pgrep bash))) > >> 4840 6474 6475 6476 > >> [j...@localhost ~]$ echo $(echo $(pgrep bash)) > >> 4840 6482 6483 > >> [j...@localhost ~]$ echo $(pgrep bash) > >> 4840 > >> [j...@localhost ~]$ pgrep bash > >> 4840 > > > why don't the last two follow the pattern? > > > but if I do this, the pattern seems to be followed nicely. > > >> [j...@localhost ~]$ echo $(echo $(pgrep bash | grep [1-9]*)) > >> 4840 6531 6532 > >> [j...@localhost ~]$ echo $(pgrep bash | grep [1-9]*) > >> 4840 6523 > >> [j...@localhost ~]$ pgrep bash | grep [1-9]* > >> 4840 > > > Can anyone explain this "pattern" problem? > > Thank you very much, guys! > > > Joey > > -- > > > "To follow the path: > > look to the master, > > follow the master, > > walk with the master, > > see through the master, > > become the master." > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Linux Users Group. To post a message, send email to [email protected] To unsubscribe, send email to [email protected] For more options, visit our group at http://groups.google.com/group/linuxusersgroup -~----------~----~----~----~------~----~------~--~---
