I have a file with a load of errors in it. I used grep to pull out all the JSONExcpetion
Errors and save them in a new file like this:
sudo grep -Hrn "JSONException" 2016-* >> jsonexception.txt
Now I have a file with a lot of JSONExceptions
in it. Some of those exceptions contain IDs. I'd like to pull out the ID's and save them to another file.
In my Java code, I use the following regex to identify the correct ID formatting in a String
:
^([A-Fa-f0-9]{24})$
Can I use something similar with grep to pull IDs from jsonexception.txt
and save them to another file?
A sample from the log:
2016-02/server-2016-02-11-3.log:17425:11/Feb/2016 12:08:35,519 [ERROR] [Thread-3] - WorkerRunnable: Worker 2: A JSONException occurred, on the string: {"DEVICE":[{" ID":"32584305d2ff32051d06dfff"},{"TimeStamp":1455185304,"Event":"Boot","BuildDate":"Feb 11 2016","BuildTime":"10:48:00","Reason":"Power on Reset","FSHigh":485,"FSLow":475 ,"VerMajor":0,"VerMinor":9,"VerRevision":2,"VerPatch":2,"MAC":"00:06:66:3a:26:5c","WlanVersion":"4.75","WlanModuleType":"RN131","BoardRev":"RevD1","DisinfectSeconds":0},{ "TimeStamp":1455185316,"Event":"CurrentSettings","IssuedTime":0,"FSHigh":535,"FSLow":425,"Duty":100,"Frequency":1000,"Current":80,"IdlePeriod":30,"StillOnPeriod":20,"Auto OnPeriod":43200,"AutoOnDuration":10,"MaxOnTime":14400,"FlowSensitivity":50,"LidSwitches":1,"UvFluxWarn":70,"UvFluxInsufficient":40,"Firm Server":"���^A.^B�^B.^P�^K�^G�^C�JF^M� �H�O�zp^HI����^C�^G�^C�^M�B�^N�^R��� ����O^B�pG�^D","FirmPort:1,"DeviceTypeName":"","WlanTimeZone":25,"LedRegArray":[{"Bo ardId":"A","LedNo":0,"RegState":"Regulate"},{"BoardId":"A","LedNo":1,"RegState":"Regulate"}]},{"TimeStamp":1455185316,"Event":"CurrentWlanSettings","SettingsArray":[{"WlanSettingsId":1},{"WlanSettingsId":2},{"WlanSettingsId":3}]},{"TimeStamp":145518531 5,"Event":"Connect","WlanSettingsId":1,"MAC":"00:06:66:3a:26:5c","IP":"192.168.1.125","WLAN":"TEST1","RSSI":-52,"Version":"4.75","AP-MAC":"ac:9e:17:ea:0f:3c"},{"End ":100}]}^M