Shell script之How to write
Write shell script:
1) Editor like vi or mcedi
2) Set execute permission for your script
chmod permission your-script-name
$ chmod +x your-script-name
$ chmod 755 your-script-name
This will set read write execute(7) permission for owner, for group and other permission is read and execute only(5).
3) Execute script
bash your-script-name
sh your-script-name
./your-script-name
In the last syntax ./ means current directory, But only . (dot) means execute given command file in current shell without starting the new copy of shell.
$ . foo
4) Practice
$ vi first
#
# My first shell script
#
clear
echo "Knowledge is Power"
$ vi ginfo
2 #
3 #
4 # Script to print user information who currently login , current date & time
5 #
clear
echo "Hello $USER"
echo "Today is \c ";date
echo "Number of user login : \c" ; who | wc -l
echo "Calendar"
cal
exit 0
5) Feng - quickly go to specific directory by shell scripts
1 #!/bin/bash
2 # ----------------------------------------------------------------------------
3 # quickly go to software development directory
4 # ---------------------------------------------------------------------------- if [ $# -eq ]; then
cd '01_Project/02_Projrct_Name/02_DIGITAL/01_src/software/embedded'
8 # list all the software development directory
ls
fi
then in your Linux terminal enter
# dot(.) can execute command file at current directory
. software.sh
Shell script之How to write的更多相关文章
- shell及脚本4——shell script
一.格式 1.1 开头 必须以 "# !/bin/bash" 开头,告诉系统这是一个bash shell脚本.注意#与!中间有空格. 二.语法 2.1 数值运算 可以用decla ...
- shell script
一.shell script的编写与执行 1.shell script 的编写中还需要用到下面的注意事项: a.命令的执行是从上到下,从左到右地分析与执行 b.命令.参数间的多个空白都会被忽略掉 c. ...
- (copy) Shell Script to Check Linux System Health
source: http://linoxide.com/linux-shell-script/shell-script-check-linux-system-health/ This article ...
- shell script练习
执行脚本的几种方式: 1. sh a.sh 或者 bash a.sh 调用的是 /bin/bash 进程执行的,所以脚本不需要执行权限. 2. 直接使用绝对路径执行, /home/script/a ...
- 这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script
这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script ##转载注明出处:http://www.cnblogs.com/wade-xu/p/4378224.html ...
- CentOS Linux下一个tomcat起停,查看日志的shell script
CentOS 的tomcat安装目录:/usr/local/tomcat vi MyTomcatUitl.sh 创建文件chmod u+x MyTomcatUtil.sh 赋执行 ...
- Shell script for logging cpu and memory usage of a Linux process
Shell script for logging cpu and memory usage of a Linux process http://www.unix.com/shell-programmi ...
- shell script入门
从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 Shell脚本编程,完成更加复杂的操 ...
- shell script 的追踪与 debug
shell script 的追踪与 debug scripts 在运行之前,最怕的就是出现语法错误的问题了!那么我们如何 debug 呢?有没有办法不需要透过直接运行该 scripts 就可以来判断是 ...
- 第十三章、学习 Shell Scripts 简单的 shell script 练习
简单的 shell script 练习 简单范例 对谈式脚本:变量内容由使用者决定 [root@www scripts]# vi sh02.sh #!/bin/bash # Program: # Us ...
随机推荐
- 用vhd挂载并安装win7且建立分差vhd
准备:硬盘分区激活第一个分区; imagex.exe; install.wim; winpe boot pc 1.cmd命令下,创建主vhd (1)diskpart (打开dis ...
- 5 shell命令之tr
这是一个奇妙的命令. tr的全拼就是translate,即翻译.有趣的是我们能够制定规则进行翻译.使用方法例如以下: tr [option] set1 [set2] tr从标准输入接受输入.然后将结 ...
- [LeetCode][Java] Jump Game II
题目: Given an array of non-negative integers, you are initially positioned at the first index of the ...
- MySQL-PREPARE语句
MySQL-PREPARE语句 功能介绍: MySQL准备语句用法 为了使用MySQL准备语句,您需要使用其他三个MySQL语句如下: PREPARE - 准备执行的声明. EXECUTE - 执行由 ...
- iOS中.pch文件怎样使用
pch 能够用来存储共享信息,比方设备屏幕的宽度,高度.版本等等 公用信息 Xcode 老版本号会自己主动为我们创建pch文件,新版本号開始不自己主动创建了.假设须要使用能够自己手动创建 waterm ...
- ABAP OLE
OLE DATA: excel TYPE ole2_object, workbook TYPE ole2_object, sheet TYPE ole2_object, cell TYPE ole2_ ...
- JFreeChart生成饼形图(3)11 (转自 JSP开发技术大全)
FreeChart生成饼形图(3) (转自 JSP开发技术大全) 14.3 利用JFreeChart生成饼形图 通过JFreeChart插件,即可以生成普通效果的饼形图,也可以生成3D效果的饼形图:如 ...
- 4.7.6 Compaction of LR Parsing Tables
4.7.6 Compaction of LR Parsing Tables A typical programming language grammar with 50 to 100 terminal ...
- EasyUI Form表单提交
转自:https://www.cnblogs.com/net5x/articles/4576926.html Form(表单) 使用$.fn.form.defaults重写默认值对象 form提供了各 ...
- angularJs模版注入的两种方式
一,声名式注入 1:app.js: var myApp = angular.module("myApp",["ngRoute"]); 2:controller. ...