Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i need to get the most recent ID of specific application. As soon as the application starts, the id should be taken. Please, help. Any idea?

Regards, Uguudei

share|improve this question
Welcome to Ask Ubuntu! What kind of ID are you talking about? process id? But there can be many as forks have their own for each of the childs. Please explain a bit further of what you're trying to accomplish. – gertvdijk Jan 18 '13 at 2:30
Imagine i have executed busybox microcom -s 57600 /dev/ttyUSB0 on terminal. And i get process id of busybox by using pidof busybox which gives me the PID. Unfortunately, i had executed busybox microcom -s 9600 /dev/ttyACM0. Then i get 2 PIDs. I need to distinguish them. I am coding on java and need to accomplish it. – Uguudei Jan 18 '13 at 2:35
Add these very very important details to your question, by editing it. This is how the site works, being a Q&A site (rather than a discussion forum). – gertvdijk Jan 18 '13 at 2:36
@gertvdijk. Thx Mate. – Uguudei Jan 18 '13 at 2:46
up vote 0 down vote accepted

For simple process id (pid) in Bash scripting, you're looking for $!:

$ kcalc & # starts calculator in background
[1] 15989
$ echo $! # shows pid of last run command

In case you want to find out the pid of a running process (example with kwin), try:

$ pidof kwin # kwin is my window manager
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.