以下代码在一个系统中正常工作,而在具有相同规格的其他系统中工作正常。
系统A:
ksh --version
version sh (AT&T Research) 93u+ 2012-08-01
uname -a
Linux ServerA 2.6.32-431.5.1.el6.x86_64 #1 SMP Fri Jan 10 14:46:43 EST 2014 x86_64 x86_64 x86_64 GNU/Linux
代码:
#!/bin/ksh
cd /home/path/
if [ `ls -1 *.log 2>/dev/null | wc -l` -gt 0 ] ; then
echo "Log files are more than Zero"
for f in `ls -1 *.log` ; do
echo $f
sleep 1
done
fi
输出:
Log files are more than Zero
file1.log
file2.log
file3.log
系统B:
ksh --version 版本sh(AT& T Research)93u + 2012-08-01
uname -a
Linux ServerB 2.6.32-431.5.1.el6.x86_64 #1 SMP Fri Jan 10 14:46:43 EST 2014 x86_64 x86_64 x86_64 GNU/Linux
代码:
#!/bin/ksh
cd /home/path/
if [ `ls -1 *.log 2>/dev/null | wc -l` -gt 0 ] ; then
echo "Log files are more than Zero"
for f in `ls -1 *.log` ; do
echo $f
sleep 1
done
fi
输出:
Log files are more than Zero
它永远挂起.....
有什么想法??