:: Re: [DNG] ID which /dev/pts/? runni…
Página Principal
Delete this message
Reply to this message
Autor: aitor
Data:  
Para: dng
Assunto: Re: [DNG] ID which /dev/pts/? running just bash?
Hi again,

On 12/2/24 21:19, aitor wrote:

> I suggest you the following command:
> $ ps --no-headers --format tty $(pgrep xterm)


I rectify. The steps would be as follows:

1) Get the pid of xterm process:

~$ ps --no-headers --format pid $(pgrep xterm)
28062

2) Get the pid of child process in xterm (the bash process):

~$ pgrep -P 28062
28070

3) Get the tty of the bash process (the child):

~$ ps --no-headers --format tty --pid 28070
pts/4

In sumary (step 1 + step 2 + step 3):

~$ ps --no-headers --format tty --pid $(ps --no-headers --format pid $(pgrep xterm) | xargs pgrep -P)

Of course, it works with the assumption that there is only one xterm window opened.

Cheers,

Aitor.