Суть скрипта — показать новые файлы в каталоге
#!/bin/bash
mkdir /tmp/backup/
echo "Not working:"
rm /var/log/newfile.txt
find /var/log/ -type f >/tmp/backup/filelistbefore.txt
touch /var/log/newfile.txt
find /var/log/ -type f >/tmp/backup/filelistafter.txt
grep -vf /tmp/backup/filelistbefore.txt /tmp/backup/filelistafter.txt >/tmp/backup/newfiles.txt
echo "New files with cat:"
cat /tmp/backup/newfiles.txt
echo "Diff:"
diff /tmp/backup/filelistbefore.txt /tmp/backup/filelistafter.txt
echo "Working:"
rm $HOME/testcatalog/newfile.txt
find $HOME/testcatalog/ -type f >/tmp/backup/filelistbefore.txt
touch $HOME/testcatalog/newfile.txt
find $HOME/testcatalog/ -type f >/tmp/backup/filelistafter.txt
grep -vf /tmp/backup/filelistbefore.txt /tmp/backup/filelistafter.txt >/tmp/backup/newfiles.txt
echo "New files with cat:"
cat /tmp/backup/newfiles.txt
echo "Diff:"
diff /tmp/backup/filelistbefore.txt /tmp/backup/filelistafter.txt
На Ubuntu 15.10 не работает, на CentOS 6 всё нормально. В чём может быть причина?
Запускаю от sudo, ошибок на выхлопе нет.
В первом случае с помощью grep не находит разницу, но с diff разница есть.
Ошибка возникает тут:
grep -vf /tmp/backup/filelistbefore.txt /tmp/backup/filelistafter.txt >/tmp/backup/newfiles.txt
echo "New files with cat:"
cat /tmp/backup/newfiles.txt