- 11
- 0
- 约1.8万字
- 约 19页
- 2015-09-26 发布于重庆
- 举报
Shell编程基础教程
1. Linux 脚本编写基础
1.1 语法基本介绍
1.1.1 开头
程序必须以下面的行开始(必须放在文件的第一行):
#!/bin/sh
符号#!用来告诉系统它后面的参数是用来执行该文件的程序。在这个例子中我们使用
/bin/sh 来执行程序。
当编辑好脚本时,如果要执行该 本,还必须使其可执行。要使 本可执行:
chmod +x filename 这样才能用./filename 来运行
1.1.2 注释
在进行shell 编程时,以#开头的句子表示注释,直到这一行的结束。我们真诚地建议
您在程序中使用注释。如果您使用了注释,那么即使相当长的时间内没有使用该 本,您
能在很短的时间内明白该脚本的作用及工作原理。
1.1.3 变量
在其他编程语言中您必须使用变量。在shell 编程中,所有的变量都由字符串组成,并
且您不需要对变量进行声明。要赋值给一个变量,您可以这样写:
#!/bin/sh
#对变量赋值:
a=hello world
# 现在打印变量a 的内容:
echo A is:
echo $a
有时候变量名很容易与其他文字混淆,比如:
num=2
echo this is the $numnd
您可能关注的文档
- PQRASME要求填写的焊接工艺评定报告.doc
- Practical Automatic Determination of Causal Relationships in Software Execution Traces.pdf
- Prediction of Physical, Color, and Sensory Characteristics of Broiler Breasts by VisibleNea.pdf
- Precision Spectroscopy of Pionic Atoms From Pion Mass Evaluation to Tests of Chiral Perturb.pdf
- Predictive Evaluation of Econometric Forecasting Models in Commodity Futures Markets.pdf
- Predicting the Performance of Randomized Parallel Search An Application to Robot Motion Pla.pdf
- PRELIMINARY VERSION A Design Diversity Metric and Analysis of Redundant Systems.pdf
- Present and NearFuture Reflected Light Searches for CloseIn Planets.pdf
- prepared for a special issue of abour Economics,.pdf
- Present and Future Electroweak Precision Measurements and the Indirect Determination of the.pdf
最近下载
- 2024年广西科技师范学院教师招聘考试笔试模拟试题及答案解析.docx VIP
- 2022年宁夏中考数学试卷.pdf VIP
- 2025年广西科技师范学院辅导员招聘考试笔试模拟试题及答案解析.docx VIP
- 山西财经大学 统计学 2021-2022-1 期末试题 .pdf VIP
- 国企集团薪酬与绩效管理办法.docx VIP
- 2025广西玉林师范学院公开招聘第二批工作人员49人考试参考试题及答案解析.docx VIP
- 中级宠物营养师必学鲜粮方向工作计划及安排.docx VIP
- 2025广西科技师范学院统一公开招聘工作人员17人考试模拟试题及答案解析.docx VIP
- (完整版)藻类图谱大全.doc VIP
- 2025年广西科技师范学院教师招聘考试笔试模拟试题及答案解析.docx VIP
原创力文档

文档评论(0)