Shell 控制是否将新文件传入带有“的文件夹”;“通信”;
如果文件夹中有新文件传入,我将在无限周期内使用comm进行查看,但我与2个文件没有区别,但例如,如果在输出中查看incominig file“a”:Shell 控制是否将新文件传入带有“的文件夹”;“通信”;,shell,command-line,ksh,Shell,Command Line,Ksh,如果文件夹中有新文件传入,我将在无限周期内使用comm进行查看,但我与2个文件没有区别,但例如,如果在输出中查看incominig file“a”: a a.out a.txt b.txt test.cpp testshell.sh a.out a.txt b.txt test.cpp testshell.sh 我的代码是: #! /bin/ksh ls1=$(ls); echo $ls1 > a.txt; while [[ 1 > 0 ]] ; do ls2=
a a.out a.txt b.txt test.cpp testshell.sh
a.out a.txt b.txt test.cpp testshell.sh
我的代码是:
#! /bin/ksh
ls1=$(ls);
echo $ls1 > a.txt;
while [[ 1 > 0 ]] ; do
ls2=$(ls);
echo $ls2 > b.txt;
#cat b.txt;
#sort b.txt > b.txt;
#diff -u a.txt b.txt;
#diff -a --suppress-common-lines -y a.txt b.txt
comm -3 a.txt b.txt;
printf "\n";
ls1=$ls2;
echo $ls1 > a.txt;
#cat a.txt;
#sleep 2;
#sort a.txt > a.txt;
done
谢谢
给出添加和删除的差异,但不使用文件。可以直接以相同的方式提供新文件,但当在前缀为
+
和-
的列表中使用时,uniq-f 1
失败(不理解原因),具体取决于源当您将变量回送到文件中时,需要对它们进行双引号以保留换行符-例如echo“$ls1”>a.txt
#! /bin/ksh
set -vx
PreCycle="$( ls -1 )"
while true
do
ThisCycle="$( ls -1 )"
echo "${PreCycle}${ThisCycle}" | uniq
PreCycle="${ThisCycle}"
sleep 10
done