shell必备知识
来源:互联网 发布:淘宝客服名 编辑:程序博客网 时间:2024/06/05 17:08
一、在shell中经常需要测试一些变量的状态,以下是部分测试条件
Comparisons:
-eqequal to-nenot equal to-ltless than-leless than or equal to-gtgreater than-gegreater than or equal toFile Operations:-sfile exists and is not empty-ffile exists and is not a directory-ddirectory exists-xfile is executable-wfile is writable-rfile is readable
二、stdin, stdout, stderr分别等于几?
The Unix / Linux standard I/O streams with numbers:
HandleNameDescription0stdinStandard input1stdoutStandard output2stderrStandard error三、shell 脚本中, $#、 $?、 #0分别代表什么?
$#:传递个脚本的参数个数
$?:最后运行命令的结束代码;
$0:shell本身的文件名
$$:shell本身的PID
$!:shell最后运行的后台进程的PID
$- :使用Set命令设定的Flag一览
$* :所有参数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。
$@ :所有参数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数。
$1~$n :添加到Shell的各参数值。$1是第1参数、$2是第2参数…。
find 搜索文件/ 搜索文件夹
搜索文件: find ./ -type f | xargs grep "key_word"
搜索文件夹: find ./ -type d | grep "key_word"
0 0
- shell必备知识
- 必备知识
- 必备知识
- .net初学者必备知识
- SOA架构必备知识
- 系统分析员必备的知识
- 编程必备知识大杂烩
- 菜鸟上网必备知识
- 生活知识必备
- 网站建设知识必备
- 测试必备知识
- 网站开发人员必备知识
- 程序员必备知识程序设计
- 发表论文必备知识
- 软件工程师必备知识
- php必备知识01
- MFC_study 必备的知识
- spring必备知识
- 【SzNOI语法百题】【d007】 求两数的整数商 和 余数
- CODEVS 1012 最大公约数和最小公倍数问题
- ACM-数塔
- 02-3. 求前缀表达式的值(25)
- Caused by: android.view.InflateException: Binary XML file line #57: Error inflating class null
- shell必备知识
- springmvc文件上传
- Gas Station
- 【Boost】Boost总结汇总
- EBS_R12_Web_ADI_使用手册
- java class loader 学习
- 图论——最短路径——floyd
- Lintcode - Topological Sorting
- iOS学习-初学者如何使用块(Block)进行传值