0

I have a hash file containing several md5 hashes. I want to create a bash script to curl virustotal to check if the hashes are known.

#!/bin/bash

for line in "hash.txt";
do
    echo $line; curl -s -X GET --url 'https://www.virustotal.com/vtapi/v2/file/report?apikey=a54237df7c5c38d58d2240xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcc0a0d7&resource='$line'';
done

but not working.

Could you help me please?

  • Take out the single quotes and put the the url in double quotes. – Raman Sailopal Oct 15 '20 at 13:20
  • Does this answer your question? [Looping through the content of a file in Bash](https://stackoverflow.com/questions/1521462/looping-through-the-content-of-a-file-in-bash) – Léa Gris Oct 15 '20 at 14:19

1 Answers1

2

Better use a while loop. Your for loop would only run once, because bash interpret it as a value, not a file. Try this:

while read -r line; do

  echo "$line"
  curl -s -X GET --url "https://www.virustotal.com/vtapi/v2/file/report?apikey=a54237df7c5c38d58d2240xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcc0a0d7&resource=$line"

done <"/path/to/hash.txt"
allxrob
  • 71
  • 3
  • Good first contribution! Although the question of looping a file content in Bash has answers already, so this may be closed in a wile. – Léa Gris Oct 15 '20 at 14:54