You're viewing a comment by Peter Krumins and its responses.

July 05, 2013, 17:57

Here is how:

awk '{ a[$1]++ } END { for (k in a) if (a[k]<2) printf k"\n" }'

You simply replace the ternary operator with if.

Comment Responses

March 05, 2014, 22:01

Yep, thats what I usually use. I wanted to know if there is a way we can use ternary operator and not define the else condition. Do we need to have both conditions explicitly stated? I know it sounds a bit rhetorical, but I just wanted to know if there is an idiomatic way of using ternary but not specifying else condition.

Keep up the good work! Your perl and awk ebooks are classic! Can't wait for bash one-liner! :)

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "unix_122": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.