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 ...
随机推荐
- QlikView格式化某一个单元格
QlikView中能够创建透视表和垂直表,或者一般的Table.假如有的时候须要某一个单元格的样式和其它单元格不一样.颜色或者边框宽度等.能够通过下面方式实现: 工具栏里面有个button叫:Desi ...
- jquery選取所有checkbox和判斷是否全部checkbox已經被勾選
前言 勾選/取消勾選 全部勾選checkbox的時候 勾選/取消勾選 所有對應的checkbox 當所有對應checkbox有別勾選的時候, 全部勾選checkbox 也要被勾選 完整程式碼範例 前言 ...
- cocos2d-x 2.2.3 建project
2.2以后不再使用模板安装了. 打开终端,进入cocos2d-x文件夹下的tools/project-creator,运行命令 ./create_project.py -project [项目名] - ...
- Python 批量修改root密码
#_*_coding:utf8_*_ from multiprocessing import Process, Pool import paramiko import sys,os host_list ...
- 玩转单元測试之DBUnit
本文同一时候发表在:http://www.cnblogs.com/wade-xu/p/4547381.html DBunit 是一种扩展于JUnit的数据库驱动測试框架,它使数据库在測试过程之间处于一 ...
- Session管理之ThreadLocal
ref=toolbar" target="_blank">ref=toolbar_logo" target="_blank"> ...
- CCBPM工作流引擎的消息机制与设计
keyword:ccflowjflow 消息机制流程引擎 自己主动发送短信 发送邮件 发送消息 流程引擎微信连接 消息接口 关于ccbpm: 我们把ccflow jflow两个版本号的工作流引擎统称为 ...
- bzoj2709: [Violet 1]迷宫花园
二分答案,spfa check就行了. gb题卡精度. #include<cstdio> #include<iostream> #include<cstring> ...
- 蓝书3.3 SPFA算法的优化
T1 最小圈 bzoj 1486 题目大意: 一个环的权值平均值为定义为一个这个环上所有边的权值和除以边数 求最小的环的权值平均值 思路: 二分一个值 把所有边减去这个值 判断是否有负环 #inclu ...
- Flask的多app应用,多线程如何体现
一.多app应用 在一个py文件中创建多个Flask的app对象 from werkzeug.wsgi import DispatcherMiddleware from werkzeug.servin ...