My code goes something like this:
echo "$result" | xargs -P50 -I@ bash -c '{ printf "@ $(curl --write-out "%{http_code}" -L -s --output /dev/null @)\n"; }'
Where result is containing a list similar to :
https://example.com/somepath
https://example.com/somepath"
https://example.com/anotherpath?par1&par4=gg
The expected output [URL STATUS-CODE]
https://example.com/somepath 200
https://example.com/somepath" 200
https://example.com/anotherpath?par1&par4=gg 200
The issue is when running this snippet, i get the error
bash: quot: No such file or directory which is separated by the andsign & and i cant seem to work around it
I tried wrapping @ in single/double quotes but nothing worked
result. Maybe it would be easier without putting the multi-line data in a single variable and splitting it usingxargs. Avoiding subshells and usingprintfwith a proper format string and modified quoting may also help. Explain in your question what you want to achieve. Based on guessing from the code and example data you somehow get a list of URLs and want to display the reply code of the web server when you try to access the URL usingcurl. Do you want to further process the reply code later? – Bodo Mar 08 '21 at 12:29printfcorrectly.printf FORMAT [ARGUMENT]like @Bodo said, then check this for safe usage ofbash -c(the question is aboutfind -exec sh -c, but the very same applies here. Also, you might get rid of the superfluous{and}. – pLumo Mar 08 '21 at 12:36resultvariable is set in different ways in the code, I showed how the final value would be, and yes you are right, i want to get the status code of each URL and i will need both urls along with the status code for later in the code. I shared a sample ofresultvariable and the expected output. – Raywando Mar 08 '21 at 12:38resultvariable is set in different ways" doesn't clarify anything. An example why it may be useful to know how you construct theresultvalue: If you generate the URLs in a loop it might be easier to callcurlin the same loop. When you generate multi-line output where every line is one value, it might be better to feed this into awhile IFS= read -r variableloop. – Bodo Mar 08 '21 at 12:47