How to know the PID of the last open file (process) using the command line?
The PID of the last process started from the terminal can be found in the ! variable:
gedit & echo $!