Issue
The following extracts almost what I want but not quite:
echo 'pie(x=x,labels=c("5.3 %","2.8 %","1.5 %","5.2 %","2.9 %","2.3 %","7.9 %","16.9 %","19.5 %","27.5 %","8.3 %"),main="ChIP",col=c("#445FA2","#EB9D86","#799F7A","#6C527F","#5FA1C1","#E8BB77","#A8C5EF","#FDCDB9","#C6E6B5","#F1D5EE","#B4E1F6"),clockwise=TRUE,border=FALSE,radius=0.9,cex=0.8,init.angle=90,density=100)'|grep -oP '(?<=").*?(?= %)'
Output is:
5.3
,"2.8
,"1.5
,"5.2
,"2.9
,"2.3
,"7.9
,"16.9
,"19.5
,"27.5
,"8.3
Would you please advise how to obtain a 'cleaner' output such as:
5.3
2.8
1.5
5.2
2.9
2.3
7.9
16.9
19.5
27.5
8.3
Preferably, please base solution on the above grep -oP , but of course other solutions are welcome!
Solution
if you want only 0-9 and "." characters you can use:
grep -oP '(?<=")[\d\.]*?(?= %)'
instead of
grep -oP '(?<=").*?(?= %)'
Note: \d in Perl matches 0-9 whereas . in Perl matches any character so you escape it to be a literal period character
Answered By - Ken Schumack Answer Checked By - Gilberto Lyons (WPSolving Admin)