CWYAlpha

Just another WordPress.com site

Thought this was cool: LinuxTips-空格的处理

leave a comment »


1 文件名中包含空格
 文件或文件名中包含空格时,需要使用单引号或者\来转意空格:
 mkdir ‘my test’ 或者 mkdir ‘my       test’;
 mkdir my\ test或者mkdir my\ \ \ \ \ test;
  
2  shell中赋值语句不能够在变量与值之间有空格,如上面的这一句:
wordnum = `cat $afile|grep html|wc -l`;
如果这样写,是肯定会报错误的,必须要写成以下这样:
wordnum=`cat $afile|grep html|wc -l`;
  
3 shell中if语句的方括号与判断条件之间一定要是两边都有空格,如这条语句:
if [$wordnum>0]; then
是有问题的,必须写成下面这样:
if [ $wordnum -gt 0 ]; then 

本文链接

from 博客园_iTech's Blog: http://www.cnblogs.com/itech/archive/2012/09/03/2669394.html

Written by cwyalpha

九月 3, 2012 在 2:39 下午

发表在 Uncategorized

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: