New answers tagged

1 vote

grep exact process name in bash script with variable argument

In shells that support it, you could use the substring expansion to put the brackets in the right places: name=ffmpeg ps -ef | grep "[${name:0:1}]${name:1}" would run grep "[f]fmpeg&...
  • 128k
0 votes

grep exact process name in bash script with variable argument

Would inverted-match with grep work? grep -v 'grep\|script' This will not match grep or script.
3 votes
Accepted

grep exact process name in bash script with variable argument

Simply run: pgrep -fl script.sh From man pgrep: pgrep, pkill, pidwait - look up, signal, or wait for processes based on name and other attributes -f, --full The pattern is normally only ...
1 vote

Passing named arguments to shell scripts

I want the script to function consistently with other utilities, providing the least surprise to the user. Here is what I came up with, combining several ideas here (especially the answer from cdmo) ...

Top 50 recent answers are included