Use a combination of 'tr' and 'head' instead which works with both the
GNU and BSD version of coreutils.
Change-Id: I5628863ed41030864ec08f45a3d4153c32fc5496
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
while IFS= read -r pid ; do
# /proc/pid/cmdline is null separated.
- if full_command_no_argument=$(cut -d '' -f 1 2>/dev/null < /proc/"$pid"/cmdline); then
+ if full_command_no_argument=$(tr '\0' '\n' < /proc/"$pid"/cmdline 2>/dev/null | head -n1); then
command_basename=$(basename "$full_command_no_argument")
if grep -q "$pattern" <<< "$command_basename"; then
echo "$pid"