我的操作系统:Fedora 13 版(Goddard)
'test' 下有 5 个目录
[root@localhost lab]# ls test
dir1 dir2 dir3 dir4 dir5
脚本1
#!/bin/bash
#below line for listing all directories under '/home/arun/lab/test'
ls -Al --time-style=long-iso /home/arun/lab/test | grep '^d' | awk '{print $8}' | while read line
do
#Need to skip few directoirs
if [ "$line" == "dir1" -o "$line" == "dir2" ]; then
continue
fi
#will take some actions here..as of now just echo only
echo $line
done
Script2 [仅修改更改 == 为 != ]
#!/bin/bash
#below line for listing all directories under '/home/arun/lab/test'
ls -Al --time-style=long-iso /home/arun/lab/test | grep '^d' | awk '{print $8}' | while read line
do
#Need to skip few directoirs
if [ "$line" != "dir1" -o "$line" != "dir2" ]; then
continue
fi
#will take some actions here..as of now just echo only
echo $line
done
脚本 1 给出预期的 o/p
[root@localhost lab]# ./test.sh
dir3
dir4
dir5
问题是: 对于脚本 2,我期望低于 o/p。但是运行时没有o / p [空白]..请帮助我。
[root@localhost lab]# ./test.sh
dir1
dir2