[D-community-offtopic] finding the depth of the current shell
EHD
ml at heriard.net
Fri May 6 03:41:50 UTC 2011
Kamaraju S Kusumanchi elucubrated on 2011-05-05:
>Inside a konsole running bash shell, If I do
>
>$ # initial konsole prompt
>$ bash # spawn a new shell
>$ bash # spawn third shell
>$ bash # spawn fourth shell
>
>Now is there any command which tells that the current shell's "depth" is 4
>as in it has three "parent shells"?
>
There might be a more direct way, but pstree will show you something
like this:
$
$ bash
$ bash
$ bash
$ pstree
<snip>
├─urxvtd─┬─bash───bash───bash───bash───pstree
</snip>
In other words, look for the line containing "pstree" in the output of
the command pstree and count the number of bash, this will give you the
depth.
--
EHD
More information about the D-community-offtopic
mailing list