Если вы перенаправите вывод на exec > path/logfile.log
, тогда ... ну, вывод будет перенаправлен в файл, а не в канал.
Попробуйте:
#!/bin/bash
{
dirname=/path
tempfile=myTempfileName
find "$dirname" -type f > "$tempfile"
sed 's_.*/__' "$tempfile" | sort | uniq -d |
while read fileName
do
grep "$fileName" "$tempfile"
done
} 2>&1 | tee -a path/logfile.log | tee 'path/scripts/tj_var1.txt'
# ^^ I guess log file should be appended.
I думаю, вы могли бы иметь только стандартный вывод в файле tj_var1.txt
:
#!/bin/bash
{
{
dirname=/path
tempfile=myTempfileName
find "$dirname" -type f > "$tempfile"
sed 's_.*/__' "$tempfile" | sort | uniq -d |
while read fileName
do
grep "$fileName" "$tempfile"
done
} | tee 'path/scripts/tj_var1.txt'
} 2>&1 | tee -a path/logfile.log
Он в основном находит повторяющиеся имена файлов и выводит его.
Просто:
dirname=/path
find "$dirname" -type f -printf "%f\n" |
sort | uniq -d |
tee -a path/logfile.log | tee 'path/scripts/tj_var1.txt'