I'm writing my own ps-command in bash, but i'm having some trouble getting cmdline. This is my code:
get_cmdline(){
if [ -f "/proc/$1/cmdline" ]; then
cat /proc/$1/cmdline | cut -d " " -f 1
else echo n/a
fi
}
But this is what i'm getting:
/opt/google/chrome/chrome-sandbox/opt/google/chrome/chrome--type=zygote
What is the easiest way to remove '--type=zygote'?
PS: I don't know command sed, so if used, I would greatly appreciate a detailed explanation
Thanks a lot
using awk:
awk will delimit the record on '--'. then i am printing field one only 1st field
using sed:
using pattern matching: