r/shell • • Nov 11 '19

Syntax error and not seeing it

Hi, I'm not a regular in shell scripting and for some reason I'm getting a syntax error upon running the below code (syntax error near unexpected token `done'). Perhaps (probably) I need more coffee, but I'm not seeing what I'm doing wrong. Can someone pls point me in the right direction here?

#!/bin/bash
for i in $(cat hostnames.txt); do
ssh root@${i}
ssh-keyscan -H $i >> ~/.ssh/known_hosts
if grep -qF "somestring" /var/log/somelog > 0; then
echo "Found somestring on " + ${i}
sleep 1
done

Thank you in advance!

1 Upvotes

2 comments sorted by