LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   sed ? (https://www.linuxquestions.org/questions/linux-software-2/sed-884513/)

dmchess 06-04-2011 10:53 AM

sed ?
 
My new router has a traffic meter on it. Unfortunatly it is only accessible from a web page with lots of JavaScript/Java in it. If anyone is employed here by netgear, Allow the user to either e-mail or ftp the data to themselves. You have an ftp server built right into the router. I managed to put a script together using firefox and iMacros. Then I format the output as a groups of MySQL insert statements which is then sent off via the script to the MySQL server. Ok, I got it working even though I had to do some things which aren't the best.

I couldn't format the insert statements with single quotes around the data items. I could get them formated with double quotes. I tried to use sed to change all of the double quotes to single quotes, but I couldn't get it to work. I ended up writing a tiny little Free Pascal program to do it.

The sed I tried was something like this:

sed s/'"'/'\''/ Traffic.dat

It would change some, but not all of them.

Snark1994 06-04-2011 11:28 AM

I think you're just missing a 'g' on the end, to replace ALL occurrences in every line.

Code:

sed "s/\"/'/g" Traffic.dat
Hope this helps,

dmchess 06-04-2011 02:54 PM

Yes that worked, thanks.:hattip:

Snark1994 06-05-2011 07:31 AM

If you don't have any other (related!) questions, then could you mark the thread as 'SOLVED', please? There should be a link to do it at the top of the page...

Thanks :)


All times are GMT -5. The time now is 01:15 AM.