আপনি আউটপুট 5 ম ক্ষেত্র তাকান করতে পারেন /proc/[pid]/stat।
$ ps -ejH | grep firefox
3043 2683 2683 ? 00:00:21 firefox
$ < /proc/3043/stat sed -n '$s/.*) [^ ]* [^ ]* \([^ ]*\).*/\1/p'
2683
থেকে man proc:
/proc/[pid]/stat
Status information about the process. This is used by ps(1). It is defined in /usr/src/linux/fs/proc/array.c.
The fields, in order, with their proper scanf(3) format specifiers, are:
pid %d The process ID.
comm %s The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out.
state %c One character from the string "RSDZTW" where R is running, S is sleeping in an interruptible wait, D is waiting in
uninterruptible disk sleep, Z is zombie, T is traced or stopped (on a signal), and W is paging.
ppid %d The PID of the parent.
pgrp %d The process group ID of the process.
session %d The session ID of the process.
নোট করুন যে আপনি ব্যবহার করতে পারবেন না:
awk '{print $5}'
কারণ সেই ফাইলটি ফাঁকা পৃথক তালিকা নয়। দ্বিতীয় ক্ষেত্র (প্রক্রিয়া নাম ফাঁকা বা এমনকি নতুন লাইন অক্ষর থাকতে পারে)। উদাহরণস্বরূপ, বেশিরভাগ থ্রেডের firefoxসাধারণত তাদের নামে স্পেস অক্ষর থাকে।
সুতরাং )সেখানে কোনও চরিত্রের শেষ ঘটনাটির পরে আপনাকে তৃতীয় ক্ষেত্রটি মুদ্রণ করতে হবে।
awk '{print $5}'প্রক্রিয়া নাম (দ্বিতীয় ক্ষেত্র) এ স্থান বা নিউলাইন অক্ষর থাকতে পারে বলে আপনাকে সঠিক উত্তর দেওয়ার নিশ্চয়তা নেই।