【发布时间】:2012-12-13 03:19:28
【问题描述】:
下面的shell脚本是test.sh,目前它可以检查第10到15个字符是否等于'000000'。但是,它还应该检查 ' ' 6 个空空格以及空文件。问题是: 1) 如何检查空文件?
filename=$1
extracted=`head -1 $filename | cut -c10-15`
if [ $extracted -eq '000000' ] ###how to check for ' ' 6 null character with or operator?
then
mv $filename new.$filename
fi
例如 输入文件:
案例1(6个0000000前后的一些字符)truefile.txt:
123456789000000161718
案例2(空文件)trueemptyfile.txt:
"there's nothing in this file. Empty. "
案例3(''前后的一些字符6个空字符)truepartialempty.txt
123456789 16171819
谢谢
还有一件事,所有这些文件都在 /temp 文件夹下
/temp> ls
test.sh truefile.txt trueemptyfile.txt truepartialempty.txt
如何运行 test.sh 来检查所有文件。谢谢你。
是吗?
sh test.sh *.*
【问题讨论】:
标签: sh