I have a script with loop like
while read host do ./script & done
I want to know the process id of the current process which is starting the ./script in background and use it in script.
Assuming a POSIX shell (like
The process ID of the current shell is in the special variable
You can pass this to a forked (backgrounded) process:
In "script", that will be the first argument, so:
There's a summary of bash special variables here.