Ad Widget

Collapse

Help with regular expressions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • androponia
    Junior Member
    • Jan 2019
    • 18

    #1

    Help with regular expressions

    Hi, i am using regular expressions in processing steps.

    This is my string:

    Device Size Used Available Use% Space saving%
    /dev/mapper/vdo_smb 100.0G 24.1G 75.9G 24% 99%

    i want to extract the 24% , that is the Use% space.


    Thanks!
  • gofree
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2017
    • 400

    #2
    ugly but works .*\/.* (.*) (.*) group 1 \1
    Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.

    Comment

    • androponia
      Junior Member
      • Jan 2019
      • 18

      #3
      Thanks gofree but it didn`t work, it is strange, works on regex, but dosent work on zabbix.

      I have also try to match with PCE regular expressions but nothing works...

      https://www.debuggex.com/cheatsheet/regex/pcre

      Thanks for your help!

      Attached Files

      Comment

      • androponia
        Junior Member
        • Jan 2019
        • 18

        #4
        I solved in combination with awk command!

        vdostats --human-readable /dev/mapper/vdo_smb | awk '{print $5}' | awk 'FNR == 2 {print}'

        Comment

        Working...