in reply to Regex help!
Basically, I need to extract disk capacity from the data center description which basically has a numeric value preceding the unit of measure like GB
...echo $x | sed "s/^[^0-9]*\([0-9]*[.]*[0-9]*\)[^0-9A-Z]*GB.*/\1/g"
Why so complicated? This should do:
echo $x | sed "s/.\+ \([0-9]\+\)GB.*/\1/g"
But as LanX says, sed(1) doesn't use PCRE. Read perlrun and perlre to understand the following:
echo $x | perl -ple 's/.+?(\d+)\s?GB.*/$1/'
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
|
---|
In Section
Seekers of Perl Wisdom