If you want to remove exactly '--type=zygote' as you said in your post, you should use sed
like this:
cat /proc/$1/cmdline | cut -d " " -f 1 | sed 's/--type=zygote//'
The command to sed
is specified in the single quotes. s
is the substitution command, its format is: s/oldstuff/newstuff/
to substitute oldstuff
with newstuff
; if newstuff
is empty line, the result is oldstuff
being removed (you effectively substitute oldstuff
with the empty line), which is what we do in our example.
If you want more universal action, e.g. removing the rest of the line starting with --
, you should do:
cat /proc/$1/cmdline | cut -d " " -f 1 | sed 's/--.*//'
The only difference to the previous example here is that we use regular expression where .
stands for "any symbol" and *
specified any number of the preceding symbol, so .*
means "any number of any symbols" and --.*
means "-- followed by any number of any symbols".
sed
is pretty powerful tool (and fun too!) so might want to take some time to read up on it.
Hope that helps!