0

I have an issue when I execute this command in Solaris:

grep -Ev "(^#|^EBM_SERVER|^$)" ${EBM_CONF} | awk -F, '{print $2"|"}' | tr -d "\n" | sed 's/|$//g'

I got this error message:

egrep:illegal option -- E
usage: egrep [-bchilnsv] [-e exp] [-f file] [string] [file] ...
egrep:syntax error

1 Answer 1

2

On Solaris, in the default environment, you get antiquated utilities.

To get more modern utilities, you need to update $PATH:

PATH=`getconf PATH`:$PATH export PATH

That will get you utilities from the 90s as opposed to from the 80s (that's hardly an exaggeration...).

Then your grep will behave more like a standard grep.

Alternatively, you could use egrep instead of grep -E.

But here, awk being a superset of egrep, you don't need egrep at all.

< "$EBM_CONF" awk -F, '! /^#|^EBM_SERVER|^$/ {print $2"|"}' |
   tr -d "\n" |
   sed 's/|$//g'

To join lines with |, you'd better use paste. Your last two commands can be replaced with paste -s -d '|' -. Or you could do the whole thing in awk:

< "$EBM_CONF" awk -F, '! /^#|^EBM_SERVER|^$/ {printf "%s", sep $2; sep = "|"}'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .