- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
教材上的shell简单示例(A simple example of shell on a textbook)
教材上的shell简单示例(A simple example of shell on a textbook)
Linux basic tutorial (Wu Xueyi)
=====================================================================
Example 4-1 shows the current date, time, execution path, user account, and directory where they are located (exam4_1, figure 4_1)
# /bin/bash!
#This, script, is, a, test!
Echo -n Date and Time is:
Date
Echo The executable path is: $PATH
Echo Your, name, is: `whoami`
Echo -n Your current directory is:
PWD
#end
File to # at the beginning of the line is a comment, ignored the execution
#! /bin/bash is used to specify the script execution for bash shell
Echo displays prompt information, and -n indicates no word wrap
Inverted quotes are used for command conversion
========================================================================
Example 4-2 double quotation marks (exam4_2, figure 4_2)
# /bin/bash!
Echo current directory is `pwd`
Echo home directory is $HOME
Echo file*.?
Echo directory$HOME
=========================================================================
Example 4-3 references to internal variables (exam4_3.sh, figure 4_3)
#/bin/sh
#my test program
Echo Number of paramenters is $#
Echo Program name is $0
Echo Paramenters as asingle string is $*
Execute:
[root@dns, root]#, bash, exam4_3.sh, San, Gu
(write out another method of execution)
===========================================================================
The use of expr
The expr command is generally used for integer values, but it can also be used for strings. General format for:
Expr argument operator argument
*********************************
Expr is also a manual command line counter.
$expr 10 + 10
Twenty
$expr 1500 + 900
Two thousand and five hundred
$expr 30 / 3
Ten
$expr 30 / 3 / 2
Five
(note that the operator has spaces left and right)
The use of multiplication, must use the backslash shielding its specific meaning. Because shell might misinterpret the meaning of the asterisk.
The 3 $expr 30
Ninety
***************************************
您可能关注的文档
- 成功实施电子不停车收费的探讨(Discussion on the successful implementation of electronic toll collection).doc
- 成都德阳绵阳(Chengdu, Deyang, Mianyang).doc
- 成都高新中国西部电子信息产业的龙头(Chengdu hi tech the leader of electronic information industry in Western China).doc
- 成长性企业如何跨越营销通路的天堑(How the growth of enterprises across the marketing channels are protected).doc
- 我 与 电 视(I and TV).doc
- 我下载的资料(The information I downloaded).doc
- 我不坏丶你会爱(汽车打铁不良的故障现象及分析)(I'm not bad, you would love (fault phenomenon and analysis of automobile iron bad)).doc
- 我与公交共成长(I grew up with the bus).doc
- 我与地坛(i and the temple of earth).doc
- 成都好的it公司(Good it company in Chengdu).doc
- 教材修改(Textbook modification).doc
- 教师招聘考试(美术专业)仿真试题及答案txt(Teacher recruitment examination (Art Major) simulation questions and answers TXT).doc
- 教材多样化(Textbook diversification).doc
- 教师综合辅导教师资格考试案例分析题七(Teacher integrated counseling case study of teacher qualification examination seven).doc
- 教师节送礼(Teacher's Day gift giving).doc
- 教材误区(Teaching material misunderstanding).doc
- 教材修订原因(Reasons for revision of teaching materials).doc
- 教师资格考试中学教育知识与能力章节考点(1.3)(Teacher qualification examination, middle school education, knowledge and competence, chapter 1.3).doc
- 教育培训行业如何开展网络营销(How to carry out network marketing in education and training industry).doc
- 教育学-课堂教学提问策略新探91266(Pedagogy - a new approach to questioning strategies in classroom teaching 91266).doc
原创力文档


文档评论(0)