i have been trying for hours but with no luck, I want to extract the (id, remote_ip, listen_addr) and put it in a txt file
I have managed to do so with
curl -s https://pastebin.com/raw/gGt524CS | grep -e "id" -e "remote_ip" -e "listen_addr" | cut -d" -f4 > text.txt
but the result I’m getting is not aligned as it should
I want it to be like that in 10 lines:
id@remote_ip:listen_addr
The result I’m getting looks like this:
9ed1e069802812f484faa68a2c6dd61f6bc1be0b
tcp://0.0.0.0:26656
88.99.61.173
8f1f37f30546275dea1f1e2a9e3828e8565f118d
tcp://0.0.0.0:26656
212.192.222.35
aac5871efa351872789eef15c2da7a55a68abdad
tcp://0.0.0.0:26656
88.218.226.79
2e8c8d2d7f84b602069fc608a151c19840642d07
tcp://0.0.0.0:26656
95.216.39.183
d4c5dcfbec11d80399bcf18d83a157259ca3efc7
tcp://0.0.0.0:26656
138.201.200.100
d82c661cfec95670271b2e55037e003ff8285741
tcp://0.0.0.0:26656
193.124.50.74
2ecf2dd998aa6fbfef370a027510d0f56026cbc3
tcp://0.0.0.0:26656
152.53.35.92
e4dcdc1218f8703a16f6cc8d7024af2457661198
tcp://0.0.0.0:26656
198.7.125.195
f1ec81f4963e78d06cf54f103cb6ca75e19ea831
tcp://0.0.0.0:26656
217.76.159.104
d6416eb44f9136fc3b03535ae588f63762a67f8e
tcp://0.0.0.0:31656
211.219.19.141
Should be like this:
[email protected]:26656
Thank you all
2
Answers
With
jq
:Output:
Resources used:
You’d be much better off using a tool that actually understands JSON, like xidel:
The pastebin-url returns JSON as text.
For actual JSON that should’ve been
Content-Type: application/json
. You can work around that by simply parsing the source with-e 'parse-json($raw)/...'
, or by forcing the input-format as shown above.