Using cURL command-line tool on Mac, How to do to this script to ask it to fetch stock data which will replace commas with NO SPACES

bashcommand linecommand-line-argumentssedunix

Example: Google Outstanding Shares are 670,000,000 and this value is collected in a txt file from Yahoo Finance API via the below script. The issue is; that numbers WITH commas or spaces are a bloody nightmare for Excel's delimiter to understand when I pull this txt file into Excel.

NB: I need the script to bring this value and all others values back WITHOUT commas OR spaces. I need 670000000 so that Excel antiquated delimiter can put the data into columns.

I have asked this a few times. Can someone put me out of my misery please before the hernia goes again and the mac gets launched out of the window. Thank you.

cd desktop/quoteUpdate
while true
  curl -o quotes.txt -s ",aapl&f=nsl1c1p2j2r"
  sed -i '.bak' 's/,/ /g' quotes.txt  # replace commas with spaces
  echo UPDATED:
  sleep 10

Best Answer

Shame on Yahoo for invalid CSV

$ cat quotes.csv 
"Google Inc.","GOOG",501.79,+0.92,"+0.18%",   678,365,000,26.36
"Apple Inc.","AAPL",106.86,-2.94,"-2.68%",  5,864,839,000,17.02

$ sed 's/[[:blank:]]*\([[:digit:],]\+\)\(,[[:digit:].]\+\)/"\1"\2/' quotes.csv 
"Google Inc.","GOOG",501.79,+0.92,"+0.18%","678,365,000",26.36
"Apple Inc.","AAPL",106.86,-2.94,"-2.68%","5,864,839,000",17.02