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 ...
随机推荐
- windows 7 忘記密碼,用“带命令行的安全模式”
net user administrator /active:yes net user tester /add net localgroup administrators tester /add
- SQL Server游标 C# DataTable.Select() 筛选数据 什么是SQL游标? SQL Server数据类型转换方法 LinQ是什么? SQL Server 分页方法汇总
SQL Server游标 转载自:http://www.cnblogs.com/knowledgesea/p/3699851.html. 什么是游标 结果集,结果集就是select查询之后返回的所 ...
- 后台进程管理工具---supervisor
supervisor是一个linux下的进程管理工具,有时须要开发一些后台服务类的程序.这类程序通常不能由于意外挂掉.所以最好能在出现意外挂掉的情况下可以重新启动,继续服务. 之前我一直採用创建dae ...
- Mac下intellij idea环境的项目的新建、配色、快捷键的配置
注:本文所使用的intellij idea是14.1.2的版本号. 一.项目的新建(以新建Java项目为例) 选中当中的"create new project". 接下来你会看到下 ...
- HDUOJ Number Sequence 题目1005
/*Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- pandas 绘图 机器学习看特征相关性
pandas 绘图 import numpy as np import tflearn from tflearn.layers.core import dropout from tflearn.lay ...
- 基于Jquery插件Uploadify实现实时显示进度条上传图片
网址:http://www.jb51.net/article/83811.htm 这篇文章主要介绍了基于Jquery插件Uploadify实现实时显示进度条上传图片的相关资料,感兴趣的小伙伴们 ...
- go语言---map
go语言---map https://blog.csdn.net/cyk2396/article/details/78890185 一.map的用法: type PersonDB struct { I ...
- 【PA 2014】Kuglarz
[题目链接] 点击打开链接 [算法] sum[i]表示前i个杯子中,杯子底下藏有球的杯子总数 那么,知道[i,j]这段区间中,藏有球的 ...
- ZOJ1450 Minimal Circle 最小圆覆盖
ZOJ1450 给定N个点(N<=100)求最小的圆把这些点全部覆盖 考虑对于三角形,可以唯一的找到外接圆,而多边形又可以分解为三角形,所以对于多边形也可以找到唯一的最小覆盖圆. #includ ...