How to get the json data used in each curl statement while using xargs and maps it to its corresponding result?
-1
votes
3
answers
4204
views
I have text file that has arguments of curl command. This is how the file looks
'https://example.com/tl/ ' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username2",}'
'https://example.com/tl/ ' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username3",}'
'https://example.com/tl/ ' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username4",}'
'https://example.com/tl/ ' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username5",}'
'https://example.com/tl/ ' -X POST -H 'Content-Type: application/json' --data-raw '{"email":"username6",}'
This is the command I use
/AbsolutePath/Inputfile.txt | xargs -P 10000 -n 10 curl -s | jq '.message'
I'm using jq , to parse json in command line
What I want is,
1) Pipe or send output of above command to another command, so that if message
has certain text, grab the email **value** used in that corresponding curl command and write to a log file or create a filename with usernameX.txt
For example, only if username2 and username5 cURL command's message = 'success', these two usernames should be written to a log file or two files username2.txt and username5.txt should be created.
Asked by sofs1
(117 rep)
Jan 4, 2022, 11:26 AM
Last activity: Jun 26, 2025, 01:07 AM
Last activity: Jun 26, 2025, 01:07 AM