my code is:
echo 'url' | parallel "if curl -ss "$url" | grep yes; then vara+="$(echo {})"; else varb+="$(echo {})"; fi"
But variables are not being set. If then statement works perfectly eg . if curl $url | grep yes; then echo done; else echo undone; fi ---> such thing works but variables are not being set
Can anyone help me find my mistake.
Desired Output: is if if curl url and grep certain word in source then that url will be appended to a variable using += and if word not found then it will be apended in another variable . Finally after script is over i want to have to variables: vara contains all url list having specific word and varb contains list of urls not having that word in source. that variables are furthet used in scripts
paralleldoesn't provide the sort of interprocess communication you are looking for.... "if curl -ss "$url" ...is parsed as a double-quoted stringif curl -ssfollowed by a completely unquoted variable reference, then the start of another double-quoted string. Also, everything like$urland$(echo {})gets interpreted and turned into fixed strings by the shell before they're passed to theparallelcommand as arguments. Put theset -xcommand before this, and you can see how bash interprets this as it runs.