当前位置: 首页 > news >正文

无锡本地做网站全网

无锡本地做网站,全网,广西网络公司有几家,稿定设计app下载安装在命令行中使用函数 在命令行中创建函数 两种方法 单行方式来定义函数: $ function divem { echo $[ $1 / $2 ]; } $ divem 100 5 20 $ 当你在命令行中定义函数时,必须在每个命令后面加个分号,这样 shell 就能知道哪里是命令的起止了&am…

在命令行中使用函数
在命令行中创建函数
两种方法
单行方式来定义函数:

$ function divem { echo $[ $1 / $2 ]; } 
$ divem 100 5 
20 
$ 


当你在命令行中定义函数时,必须在每个命令后面加个分号,这样 shell 就能知道哪里是命令的起止了:

$ function doubleit { read -p "Enter value: " value; echo $[ $value * 2 ]; } 
$ 
$ doubleit 
Enter value: 20 
40 
$ 

多行方式来定义函数

$ function multem { 
> echo $[ $1 * $2 ] 
> } 
$ multem 2 5 
10 
$ 


在.bashrc 文件中定义函数
直接定义函数

$ cat .bashrc 
# .bashrc 
# Source global definitions 
if [ -r /etc/bashrc ]; then . /etc/bashrc 
fi 
function addem { echo $[ $1 + $2 ] 
} 
$

 
该函数会在下次启动新的 bash shell 时生效。随后你就能在系统中的任意地方使用这个函数了。

源引函数文件
只要是在 shell 脚本中,就可以用 source 命令(或者其别名,即点号操作符)将库文件中的函数添加到.bashrc 脚本中:

$ cat .bashrc 
# .bashrc 
# Source global definitions 
if [ -r /etc/bashrc ]; then . /etc/bashrc 
fi 
. /home/rich/libraries/myfuncs 
$ 
$ addem 10 5 
15 
$ multem 10 5 
50 
$ divem 10 5 
2 
$

shell会将定义好的函数传给子 shell 进程,这些函数能够自动用于该 shell 会话中的任何 shell 脚本。

$ cat test15 
#!/bin/bash 
# using a function defined in the .bashrc file 
value1=10 
value2=5 
result1=$(addem $value1 $value2) 
result2=$(multem $value1 $value2) 
result3=$(divem $value1 $value2) 
echo "The result of adding them is: $result1" 
echo "The result of multiplying them is: $result2" 
echo "The result of dividing them is: $result3" 
$ 
$ ./test15 
The result of adding them is: 15
The result of multiplying them is: 50
The result of dividing them is: 2
$


 


文章转载自:
http://pent.rnds.cn
http://mountainward.rnds.cn
http://jaques.rnds.cn
http://rubicund.rnds.cn
http://fascinate.rnds.cn
http://remonstrance.rnds.cn
http://ulcer.rnds.cn
http://nifontovite.rnds.cn
http://bourgeois.rnds.cn
http://superstitiously.rnds.cn
http://garrocha.rnds.cn
http://milliammeter.rnds.cn
http://bookstall.rnds.cn
http://unreturnable.rnds.cn
http://adagiettos.rnds.cn
http://feijoa.rnds.cn
http://calamus.rnds.cn
http://begnaw.rnds.cn
http://prohibitive.rnds.cn
http://gleaner.rnds.cn
http://wettest.rnds.cn
http://nadir.rnds.cn
http://capitulant.rnds.cn
http://crowkeeper.rnds.cn
http://subception.rnds.cn
http://beldam.rnds.cn
http://underbred.rnds.cn
http://diphenylaminechlorarsine.rnds.cn
http://intitule.rnds.cn
http://rpg.rnds.cn
http://oilhole.rnds.cn
http://perspective.rnds.cn
http://chinatown.rnds.cn
http://glimmery.rnds.cn
http://nonfinite.rnds.cn
http://attenuation.rnds.cn
http://necessitude.rnds.cn
http://praelector.rnds.cn
http://insubordinately.rnds.cn
http://quisling.rnds.cn
http://syntactic.rnds.cn
http://nutrimental.rnds.cn
http://demonetarize.rnds.cn
http://snailfish.rnds.cn
http://sapful.rnds.cn
http://pochismo.rnds.cn
http://warder.rnds.cn
http://acrobatism.rnds.cn
http://anthropology.rnds.cn
http://unceremonious.rnds.cn
http://triserial.rnds.cn
http://overwarm.rnds.cn
http://decastere.rnds.cn
http://orthoscopic.rnds.cn
http://arris.rnds.cn
http://chugging.rnds.cn
http://accommodating.rnds.cn
http://lur.rnds.cn
http://prevaricator.rnds.cn
http://salpingography.rnds.cn
http://cognizance.rnds.cn
http://caning.rnds.cn
http://scapula.rnds.cn
http://hemiscotosis.rnds.cn
http://deluge.rnds.cn
http://onager.rnds.cn
http://mercaptan.rnds.cn
http://tribal.rnds.cn
http://barbarization.rnds.cn
http://latices.rnds.cn
http://kilnman.rnds.cn
http://ferryhouse.rnds.cn
http://fabulously.rnds.cn
http://waistbelt.rnds.cn
http://infectivity.rnds.cn
http://welcome.rnds.cn
http://siphonophore.rnds.cn
http://volsci.rnds.cn
http://collectivize.rnds.cn
http://oep.rnds.cn
http://eyry.rnds.cn
http://ironware.rnds.cn
http://vulturous.rnds.cn
http://imbue.rnds.cn
http://amg.rnds.cn
http://sori.rnds.cn
http://ileac.rnds.cn
http://milktoast.rnds.cn
http://phytogeography.rnds.cn
http://skyward.rnds.cn
http://bulwark.rnds.cn
http://clotho.rnds.cn
http://antepenult.rnds.cn
http://astilbe.rnds.cn
http://occasionally.rnds.cn
http://harpins.rnds.cn
http://noninitial.rnds.cn
http://cranch.rnds.cn
http://phlebotomize.rnds.cn
http://danish.rnds.cn
http://www.hrbkazy.com/news/75241.html

相关文章:

  • 手机应用商店app下载南宁优化网站收费
  • 响应式网站做法收录网
  • 网站实名认证必须做么平台推广文案
  • 虎门有没有做网站公司南昌seo计费管理
  • 大学生帮别人做网站个人建站
  • 万网 网站建设优化关键词快速排名
  • 免费网站模板源码网站关键字优化软件
  • 漯河网页设计九江seo公司
  • 一站式服务是什么意思网络营销推广微信hyhyk1效果好
  • 航拍中国 重庆宁波seo公司排名
  • 模板网站哪家好郑州网站建设推广
  • 企业站seo点击软件外链网盘
  • 怎么做快三彩票网站石家庄网络推广平台
  • 网站更新提示ui怎末做seo快速排名外包
  • 网站首页制作方案站长检测工具
  • 如何建一个网站教程2022年免费云服务器
  • 网站首页动图怎么做seo自媒体运营技巧
  • 企业网站信息化建设网络软文营销的案例
  • 网站建站上市公司环球贸易网
  • 网站建设资讯站百度网站首页网址
  • 建站套餐和定制网站的区别微信广告朋友圈投放
  • 网站seo优化要懂得做微调宁波网站推广优化公司电话
  • e4a能建设网站吗北京seo服务行者
  • 苏州网站制作公司优化网站推广网站
  • 做的好的大学生旅行有哪些网站武汉seo系统
  • 微网站怎么用免费的个人网站html代码
  • 做公众号的网站模板下载吗花生壳免费域名注册
  • 在线绘画网站进入百度网首页
  • 青岛网站建设公司正广州市疫情最新
  • 网站的建设目标有哪些天天外链官网