shell脚本编程基础--``与''符号的区分
来源:互联网 发布:unity3d 2d角色朝向 编辑:程序博客网 时间:2024/05/19 00:39
一失足成千古恨,再回头已百年神!!!!!Fuck
在shell脚本编程时,编写统计当前目录下的文件数,小小的错误竟然出现在一个符号上,``与''符号的区分:
#!bin/sh
counter=0
for files in * # 替换符*表明对当前目录中所有文件循环
counter=0
for files in * # 替换符*表明对当前目录中所有文件循环
do
counter=`expr $counter + 1` # expr:对表达式求值的命令
done # let counter=$counter+1
echo "There are $counter files in `pwd` we need to process"
运行结果是:
[root@localhost shell实验]# ls
hello.c hello.sh hi.sh s2 s3 s4 s5 s6 s7 s8
[root@localhost shell实验]# sh s8
There are 10 files in /home/shell实验 we need to process
hello.c hello.sh hi.sh s2 s3 s4 s5 s6 s7 s8
[root@localhost shell实验]# sh s8
There are 10 files in /home/shell实验 we need to process
#!bin/sh
counter=0
for files in * # 替换符*表明对当前目录中所有文件循环
do
counter='expr $counter + 1' # expr:对表达式求值的命令
done # let counter=$counter+1
echo "There are $counter files in `pwd` we need to process"
运行结果是:
[root@localhost shell实验]# sh s8
There are expr $counter + 1 files in /home/shell实验 we need to process
There are expr $counter + 1 files in /home/shell实验 we need to process
所以:
counter='expr $counter + 1' ,'' 单撇号不是对counter的运算,只是对counter简单的替换
counter=`expr $counter + 1`,``才是能够进行counter运算
- shell脚本编程基础--``与''符号的区分
- shell脚本编程的基础与细节
- 【脚本学习】区分shell与shell脚本
- shell 脚本-符号-基础语法
- Shell脚本的符号
- 【shell脚本】shell的符号
- Shell脚本编程基础
- Shell脚本编程基础
- Shell脚本编程基础
- shell脚本编程基础
- shell编程基础 脚本
- Shell脚本编程基础
- Shell脚本编程基础
- shell脚本编程基础
- Shell脚本编程基础
- shell脚本编程基础
- shell脚本编程基础
- SHELL脚本编程基础
- new关键字“隐藏”父类的成员
- 细节成就卓越——浅析iPhone用户界面设计精粹
- weblogic 文件上传和下载路径
- 单线程固定大小对象的内存池实现
- java枚举与可变参数
- shell脚本编程基础--``与''符号的区分
- matlab中的矩阵是行优先还是列优先?
- C# 中 Struct 与 Class 的区别,以及两者的适用场合(转载)
- C#访问权限修饰符(转)
- 算法练习-题目1005:Graduate Admission
- 搜狗输入法特殊用法
- ※设计模式※→☆创建型模式☆============Prototype模式(六)
- 使用CATextLayer
- JAVA学习笔记(一) 环境变量配置