[ art / civ / cult / cyb / diy / drg / feels / layer / lit / λ / q / r / sci / sec / tech / w / zzz ] archive provided by lainchan.jp

lainchan archive - /tech/ - 34940



File: 1487955365432.png (103.19 KB, 300x300, R-9812109.jpg)

No.34940

What's the recommended linux command for filtering piped output ? If I have a command that outputs something like:

ofi
gym_las 9/200
olm

Can I pipe this into something so the output is just 9 ?
should I look intro grep and regex ?

  No.34941

Grep is good enough with with ERE and only-matching options:
$ echo -e 'ofi\ngym_las 9/200\nolm' | grep -oE '9'

  No.34944

Sorry, I forgot to mention, the text changes all the time, and I just want x from x/y no matter what line it is.

  No.34968

You will want to look into sed, or sed combined with grep. Also depending on the formatting awk may come in handy.

For future reference this probably should have been asked in the technical talk thread.

  No.35078

>>34944
Let's see if I can do this from my phone...

<Some command> | sed -e "/\d\+\/\d\+/ s/\(\d\+\)\/\d\+/\1/"

Something like that...