I am having trouble with a sed edit. When I run:
close=`curl 'https://finance.yahoo.com/quote/INTC?p=INTC&.tsrc=fin-srch'|html2text|sed -n '/Add to watchlist/,$p'|sed -n '/At close\:/q;p'|head -n-1|tail -n+3`; echo $close I get: 45.60+0.21 (+0.46%)
But when I add an additional sed command, to strip away everything but the floating number before either the first + or -, like so:
close=`curl 'https://finance.yahoo.com/quote/INTC?p=INTC&.tsrc=fin-srch'|html2text|sed -n '/Add to watchlist/,$p'|sed -n '/At close\:/q;p'|head -n-1|tail -n+3|sed -n '/^\([0-9]*\.[0-9]*\)[+-].*$/\1/'`; echo $close my output (echo) is empty. Any ideas what I am missing?
sed -n? Why-n?echo '45.60+0.21 (+0.46%)' | sed -n '/^\([0-9]*\.[0-9]*\)[+-].*$/\1/'-nhas nothing to do with piping instead of printing. It tellssedonly to generate output if there's an explicit print instruction