Talvez algo assim:
#!/bin/bash
while true; do
diff -q <(head -n 1 fileA.txt) <(head -n 1 fileB.txt)
sleep 5
done
Considerando esses dois arquivos ( fileA.txt
e fileB.txt
):
cat fileA.txt fileB.txt
foo
bar
foo
bar
Quando altero a linha primeiro em fileA.txt
:
cat fileA.txt
fooo
bar
Eu recebo esta saída do script:
./checkFirst.sh
Files /dev/fd/63 and /dev/fd/62 differ
Files /dev/fd/63 and /dev/fd/62 differ
Files /dev/fd/63 and /dev/fd/62 differ
Files /dev/fd/63 and /dev/fd/62 differ
Se eu alterar a linha segunda , nada acontece no script, apenas continua em loop:
cat fileA.txt
foo
barbara
Testado com o Mac OS X 10.11.6 e:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.