bash - Awk: Drop last record separator in one-liner -


i have simple command (part of bash script) i'm piping through awk can't seem suppress final record separator without piping sed. (yes, have many choices , mine sed.) there simpler way without needing last pipe?

dolls = $(egrep -o 'alpha|echo|november|sierra|victor|whiskey' /etc/passwd \ | uniq | awk '{irs="\n"; ors=","; print}'| sed s/,$//); 

without sed, produces output echo,sierra,victor, , i'm trying drop last comma.

you don't need awk, try:

egrep -o ....uniq|paste -d, -s 

here example:

kent$  echo "a b c"|paste -d, -s a,b,c 

also think chained command simplified. awk things in one-liner.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -