《Linux的脚本之shell_第一个脚本当然还是helloWorld比较好》
2017-06-17 22:12
323 查看
一》Linux的脚本一直觉着是一个很高大上的技术,知道一天构思问道/~ 小石啊,写个脚本来启动/关闭服务(tomcat X 6)
二》基于《哈佛图书馆墙上的训言》(以下简称《训言》),《训言》中的第五条
三》万丈高楼平地起。合抱之木生于毫末。九层之台起于垒土。千里之行始于足下。
①:通过touch命令创建文件helloWorld.sh
②:通过vim或者vi(推荐使用vim 高亮色彩编辑)
#!/bin/bash
say="smith says"
method="louldly"
echo $say hello world $method !
注:“=”两边不要留有空格
按ESC之后shift+zz或者:wq保存编辑修改
③:为脚本文件添加可执行权限
chmod a+x helloWorld.sh
④:运行脚本的三种方式
1>直接执行具有“X"权限的脚本文件
./helloWorld.sh
2>使用指定的解释器程序执行脚本文件
sh helloWorld.sh 或者bash helloWorld.sh
3>通过source命令(或者” . ”)读取脚本内容执行
source helloWorld 或者 . helloWorld.sh
⑤:输出为“ smith says hello world louldly ! ”
二》基于《哈佛图书馆墙上的训言》(以下简称《训言》),《训言》中的第五条
三》万丈高楼平地起。合抱之木生于毫末。九层之台起于垒土。千里之行始于足下。
①:通过touch命令创建文件helloWorld.sh
②:通过vim或者vi(推荐使用vim 高亮色彩编辑)
#!/bin/bash
say="smith says"
method="louldly"
echo $say hello world $method !
注:“=”两边不要留有空格
按ESC之后shift+zz或者:wq保存编辑修改
③:为脚本文件添加可执行权限
chmod a+x helloWorld.sh
④:运行脚本的三种方式
1>直接执行具有“X"权限的脚本文件
./helloWorld.sh
2>使用指定的解释器程序执行脚本文件
sh helloWorld.sh 或者bash helloWorld.sh
3>通过source命令(或者” . ”)读取脚本内容执行
source helloWorld 或者 . helloWorld.sh
⑤:输出为“ smith says hello world louldly ! ”
相关文章推荐
- Shell脚本判断Linux系统是32位还是64位的几种方法分享
- 【学习Linux】第一个shell脚本
- Shell脚本判断Linux系统是32位还是64位的几种方法分享
- (shell笔记五)第一个shell脚本 helloworld与read命令使用
- Linux脚本(shell)编程(一) 简单入门HelloWorld
- Shell脚本中,如何判断Linux系统是32位还是64位?
- Linux学习之第一个shell脚本
- Linux脚本(shell)编程(一) 简单入门HelloWorld
- 第一个shell脚本-helloworld
- Linux脚本(shell)编程(一) 简单入门HelloWorld
- 在linux中常用的shell备份脚本
- Linux 系统学习 之 shell脚本学习
- ORACLE自动备份并且自动FTP到备份机的SHELL脚本(http://doc.linuxpk.com/456.html)
- lua小脚本还是很像bash shell的,还是看看说明好好学习一下吧.
- 如何在Linux系统编写 shell 脚本(初级)
- Linux/Unix实现自动ftp的shell脚本
- Linux上执行Tcl脚本与Tcl环境下执行脚本,还是有些区别的。(Tcpdump命令)
- Beginning Linux Programming----shell脚本程序实例
- 在linux中常用的shell备份脚本(波大帅哥)
- 我的第一个在Linux中的极为简单的Python脚本