Hi there. I have a similar requirement to extract a specific piece information from the output of a Linux command. I'm running a iwlist to get all BSSID names (ESSID field). Here's the code followed by the output:
iwlistCmd := exec.Command("iwlist", iface, "scan") iwlistCmdOut, err := iwlistCmd.Output() if err != nil { fmt.Println(err, "Error when getting the interface information.") } else { fmt.Println(string(iwlistCmdOut)) } Output sample: wlan0 Scan completed : Cell 03 - Address: 58:20:B1:5E:FF:4D Channel:1 Frequency:2.412 GHz (Channel 1) Quality=32/70 Signal level=-78 dBm Encryption key:on ESSID:"HP-Print-4D-Officejet Pro 8610" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s 11 Mb/s; 12 Mb/s; 18 Mb/s Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s Mode:Master Extra:tsf=000004cd803ec2a9 Extra: Last beacon: 3532ms ago IE: Unknown: 001E48502D5072696E742D34442D4F66666963656A65742050726F2038363130 IE: Unknown: 010802040B0C12161824 IE: Unknown: 030101 IE: Unknown: 2A0100 IE: IEEE 802.11i/WPA2 Version 1 Group Cipher : CCMP Pairwise Ciphers (1) : CCMP Authentication Suites (1) : PSK IE: Unknown: 32043048606C IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00 IE: Unknown: DD890800090004000000070102010002017803284850204F66666963656A65742050726F203836313000000000000000000000000000000000000000040F38363130000000000000000F434E350510434E353732463331393300000000000006101C852A4DB8001F08ABCD5820B15EFF4C07040A8294B5080200D4090200080A04000000010B0400000000 Cell 06 - Address: 0A:18:0A:37:6F:E6 Channel:6 Frequency:2.437 GHz (Channel 6) Quality=27/70 Signal level=-83 dBm Encryption key:on ESSID:"WKGuest" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s 9 Mb/s; 12 Mb/s; 18 Mb/s Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s Mode:Master Extra:tsf=0000007fed31c00c Extra: Last beacon: 3248ms ago IE: Unknown: 0007574B4775657374 IE: Unknown: 010882848B960C121824 IE: Unknown: 030106 IE: Unknown: 0706555320010B1E IE: Unknown: 2A0100 IE: Unknown: 32043048606C IE: Unknown: 2D1AAD011BFFFFFF0000000000000000008000000000000000000000 IE: Unknown: 3D1606000500000000000000000000000000000000000000 IE: Unknown: DD180050F2020101810003A4000027A4000042435E0062322F00 IE: Unknown: DD0900037F01010000FF7F IE: Unknown: DD0D00180A001F0000000000000000 IE: IEEE 802.11i/WPA2 Version 1 Group Cipher : CCMP Pairwise Ciphers (1) : CCMP Authentication Suites (1) : PSK An thoughts? Thank you. Ulysses. On Tuesday, 5 July 2016 20:18:01 UTC-7, Freeman Fridie wrote: > > I have a data file with records in the following format: > > [field 1][field 2][field 3][field 4]... > > I need to be able to split the record into fields using [ ] as the > delimeter. I assume I need to use regex, but I'm unsure how to proceed. > > thanks, > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.