EdgarsK Posted February 21, 2013 Report Share Posted February 21, 2013 Hi, man ir fails kura ir json strings. Man vajaga izgrepot ara no {...},{...}... visus objektus kuros ir kaut kada veida teksts kuru mekleju, piemeram "Govs" so, ja man teksts ir: [{"a":123,"b":"riepa"},{"a":124,"b":"govs"},{"a":125,"b":"zivs"},{"a":126,"b":"lampa"},{"a":127,"b":"govs"},{"a":128,"b":"galds"}] man rezultata jasanjem 0={"a":124,"b":"govs"} 1={"a":127,"b":"govs"} kads ir kautko tadu darijis? centos visadi, ar awk, sed, grep .. laikam nemau tik labi. Ideja ir skaidra +- \{(.*)govs(.*)\} \{(.*)(\bGovs\b)(.*)\} .. bet ka lai pareizi visu izdara ta lai izsaucot bash skriptu: script.sh MySearch es rezultata sanjemu pliku stringu ar visiem rezultatiem kuri matcoja Paldies, ja kadam izddoas izdomat Quote Link to comment Share on other sites More sharing options...
marrtins Posted February 21, 2013 Report Share Posted February 21, 2013 Mož labāk paņem kādu json parseri priekš bash, piemēram, https://github.com/kristopolous/TickTick Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted February 21, 2013 Author Report Share Posted February 21, 2013 man fails ir +- 500mb liels un tadi ir vairaki, velos tikai izgrepot ara stringu Quote Link to comment Share on other sites More sharing options...
marrtins Posted February 21, 2013 Report Share Posted February 21, 2013 Kautkā tā? Strings nāk no faila data #!/bin/bash m="govs" p="\{[^\{]*$m[^\{\}]*\}" c=0 for l in `cat data | grep -o "$p"`; do echo $c=$l c=$((c+1)) done Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.