I am aiming to loop through a CSV file in bash, i have some code that is semi working. It does not seem to be completing the cURLs as the command instantly finishes and adds to the fail file. It is reading a single column CSV of URLs.
I have researched with no success, looking at GREP success codes etc. This is just being ran locally on MACOS.
INPUT=test.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read col1
do
if curl -L -s "$col1" | grep -q "string"; then
echo "${col1}" >> one.txt
else
echo "${col1}" >> two.txt
fi
done < $INPUT
IFS=$OLDIFS
I have also tried the following on the IF line:
if [[ $(curl -L -s "$col1" | grep -q "string") ]]; then
Thanks
doadd a lineecho $col1so that you can see if what you get from readingtest.csvis really what you want.curl: (3) Illegal characters found in URLso it must be the URL in cURL