Perl:
~$ zsh
~% printf 'VmRSS:\t20452 kB' | perl -lpe 's/^VmRSS\:\t//;'
20452 kB
~% bash
~$ printf 'VmRSS:\t20452 kB' | perl -lpe 's/^VmRSS:\t//;'
20452 kB
Raku:
~$ zsh
~% printf 'VmRSS:\t20452 kB' | raku -pe 's/^VmRSS\:\t//;'
20452 kB
~% bash
~$ printf 'VmRSS:\t20452 kB' | raku -pe 's/^VmRSS:\t//;'
20452 kB
Also for Raku, you have various trim
, trim-leading
, and/or trim-trailing
functions built-in. For those times when you just need to get rid of whitespace and don't care if it's spaces or tabs, etc.:
~$ zsh
~% printf 'VmRSS:\t20452 kB' | raku -pe 's/^VmRSS\://;' | raku -ne '.trim-leading.put;'
20452 kB
~% bash
~$ printf 'VmRSS:\t20452 kB' | raku -pe 's/^VmRSS://;' | raku -ne '.trim-leading.put;'
20452 kB
MacOS Ventura 13.4
zsh 5.9 (x86_64-apple-darwin22.0)
GNU bash, version 5.1.8(1)-release (x86_64-apple-darwin15.6.0)
tr -d
could do, but (like awk) sed can do the whole job at once:sed -n 's/VmRSS:\t//p' /proc/N/status
– dave_thompson_085 Jun 18 '23 at 22:19