http://www.perlmonks.org?node_id=1229181


in reply to extracting value in a string after checking value after colon ':'

Hi t-rex

While there’s not much more value to be added beyond Athanasius’ response; (assuming your data resides in "file.txt") here's the obligatory one-liner:

perl -lwne "print $1 if /(\d+)\s+cpus:\s*$/" file.txt

Best of luck
Shadowsong

  • Comment on Re: extracting value in a string after checking value after colon ':'
  • Download Code