Parse table data

September 14, 2010 at 00:09:09
Specs: Windows XP
HI.
I have a table like this:

| Aborted_clients | 18 |
| Bytes_received | 792409128 |
| Bytes_sent | 33679440 |
| Com_admin_commands | 0 |

(actualy this is mysql extended-status return)
With findstr i can parse it for specific parametr i need.

But I cant get its value... Help, plz

PS Simply:
I have "| Bytes_sent | 33679440 |" string
I need to get 33679440 as variable in script...


See More: Parse table data

Report •


#1
September 14, 2010 at 00:39:44
findstr is useless when you want to do something more advanced than finding strings.

download gawk for windows then do this

C:\test>gawk.exe -F"|" "/Bytes_sent/{print $3}" file

if you already save to a file. Or , straight from mysql output

c:\test> mysql ....   | gawk.exe -F"|" "/Bytes_sent/{print $3}" 

GNU win32 packages | Gawk


Report •

#2
September 14, 2010 at 01:08:01
I forget to say that....

ONLY NATIVE(win) solutions. No extended apps.

If it helps, in linux I use: cut -d'|' -f3 and now need same on win...


Report •

#3
September 14, 2010 at 02:02:54
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=2 delims=| " %%a in ('find "Bytes_sent" ^< myfile') do (
set V=%%a
)
echo.!V!


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
September 14, 2010 at 05:08:51
Thanx. Perfect.

Report •

#5
September 15, 2010 at 15:40:23
Someone should probably point out it's easier to just dump the query's output into a CSV file directly.

Report •

Ask Question