I have a text file whose contents looks like this:  {result:true,last:0.02094,high:0.0213,low:0.01682,avg:0.01871,sell:0.02094,buy:0.02054,vol_ltc:5145.8262,vol_btc:96.29887,rate_change_percentage:23.47}`(This is data from an API)I want it formatted so my program can read it, but I need to extract the numbers because some of the exchanges are formatted differently by the API, for example, this:  {result:true,last:0.00000070,high:0.00000073,low:0.00000069,avg:0.00000071,sell:0.00000071,buy:0.00000069,vol_doge:71072621.657,vol_btc:50.64272,rate_change_percentage:0.00}(Difference: quotes around price values)And I need something that looks like this:(Using the first one)0.020940.02130.016820.018710.020940.020545145.826296.2988723.47Alternatively something like this (again, using the first one)last0.02094high0.0213low0.01682avg0.01871sell0.02094buy0.02054vol_ltc5145.8262vol_btc96.29887rate_change_percentage23.47If you need more examples of strings provided from the API, go to http://data.bter.com/api#tickers
Extract numbers from a text file and place them in another file
shell script;osx
As the API returns JSON objects, I'd use a JSON parser for it, combined with sed and grep.I've decided for jq, which is contained in the Ubuntu repo's, so it could be installed using sudo apt-get install jq; I don't know what distro you are using, so you'll have to find that by yourself if you want to use this solution.jq .[] <filename> | sed s/\//g | grep -P '^\d+(\.\d+)$'Now, let me split this up:jq .[] <filename> will print the value for each key in the map. This probably doesn't work with nested maps, though.sed s/\//g will strip the list of any quotation marks.grep -P '^\d+(\.\d+)?$' will return those lines that consist of integer or decimal numbers only.This command chain will print the result to stdout. To get it into a file, simply pipe the output into it:jq .[] <filename> | sed s/\//g | grep -P '^\d+(\.\d+)$' > <other_filename>