owned

Apr. 24th, 2013 02:24 pm
zorkian: A picture of Oliver sitting up with his Dreamwidth onesie on! (Default)
[personal profile] zorkian
[21:16] < wmoss> #server can anyone think of a way to print all lines that have two or more commas? without removing all the data?
[21:16] < wmoss> I worried this requires awk :(
[21:18] < mark> hm
[21:18] < mark> cat test | perl -ni -e '$n=$_; print $n if (s/[^,]//g && length($_) >= 2);'
[21:19] < erin> mark: haha, I don't know if that's better than awk :P
[21:19] < mark> well,
[21:19] < mark> it's certainly less awk-ward
[21:20] < erin> perl-ward
[21:20] < mark> oh come on, nobody liked the pun?
[21:20] < erin> !m mark
[21:20] < bumpbot> you're doing good work, mark!
[21:20] < mark> I expected things to be thrown
[21:20] < dowski> !clap mark
[21:20] * bumpbot claps quietly for mark, profoundly unimpressed.
[21:20] < mark> wmoss: ^^ btw
[21:23] < wmoss> yup
[21:23] < wmoss> !thank mark
[21:23] < bumpbot> you're doing good work, mark!
[21:23] < erin> wmoss: why can't you just do
[21:23] < erin> grep ".*,.*,.*" ?
[21:23] < mark> erin .. might have won this round
[21:23] < wmoss> indeed


Wherein Mark and Will come up with a solution to identify lines with more than one comma and are proud, then Erin comes in and totally destroys them.

Well played, Erin, well played.

(no subject)

Date: 2013-04-24 11:42 pm (UTC)
alierak: (Default)
From: [personal profile] alierak
Heh. and Erin also demonstrates the totally unnecessary use of leading and/or trailing .* in unanchored regexps. grep ',.*,' much?

(no subject)

Date: 2013-04-28 02:05 am (UTC)
tcpip: (Default)
From: [personal profile] tcpip
First grep, then sed, then awk, then perl :)