建立一个规范的shell脚本
2015-11-30 00:00
567 查看
脚本开头第一行指定解释器 #!/bin/bash或者#!/bin/sh 这行内容必须在脚本文件的第一行 其他位置就认为注释了 #!/bin/bash # 作者 # 功能说明 # 版本 #===================================== #代码注释说明 代码块1 #代码注释说明 代码块2 #===================================== 实例 #!/bin/bash # # author:eddy date:2015-11-30 # 打印100个数字 # version:1.0 #循环1-100 for i in {1..100} do #打印变量 echo $i done 执行方式: 1. chmod +x script.sh---->./script.sh 2. /bin/bash script.sh 3. source sctipt.sh或者 . sctipt.sh 注意source脚本里面改变的环境变量会影响到当前shell的环境 #!/bin/bash # # cd /tmp [root@eddy script]# sh test3.sh [root@eddy script]# source test3.sh [root@eddy tmp]#
相关文章推荐
- shell脚本监控目录下文件被篡改时报警
- 在VMWare虚拟机中安装ubuntu系统后,登进系统,桌面没有任何图标,可以用xshell远程连接
- 【Linux学习笔记】Shell 基础(3) — Shell流程控制语句
- 初识SHELL
- shell 11-29
- 全新 Mac 安装指南(编程篇)(环境变量、Shell 终端、SSH 远程连接)
- linux shell
- shell 脚本之条件测试用法
- 小项目-linux下简单shell
- Linux终端的总结和shell
- 【Linux运维入门】windows环境下操作Linux的两大利器-Xshell & WinSCP
- 通用shellcode的编写、调用 实验缓冲区溢出攻击(非远程)调用shellcode实例(二)
- linux shell对应的配置文件是怎么被执行的呢?-----聊聊/etc/profile, ~/.bash_profile, ~/.bashrc等配置文件的执行流程
- linux shell中的变量PS1------定制linux shell提示符
- shell脚本的各种判断
- shell中的特殊变量和函数传参
- Shell时间(date)相关命令
- Shell时间(date)相关命令
- shell随机数生成
- Shell学习笔记 - 循环语句