shell bash-shell
bash shell中的命令替换,`cmd`或者$(cmd)。
bash shell中的变量赋值,直接name = var; (bash中的变量赋值不能中间有空格)
变量引用时,$name,如果name比较复杂,也可以是${name}
取消变量的设置,unset,unset name
bash中的for循环方式:
1) for i in 1 2 3 4 5
do
echo "$i----->$(uptime)"
done
也可以写为
for i in $(seq 1 10)
for i in {1..10}
num="1 2 3 4"
for i in $num
2) for i in `ls ./*.tar.gz`
do
tar -zxvf $i >/dev/null
done
该方法也可以拿到当前路径下文件名并放在一个列表中。
for i in `ls -1`
3)sum=0
for (i=0; i<100; i++)
do
sum=$(expr $i \* 3+1)
echo sum
done
bash中$#表示命令行输入的cmd参数的个数,$?表示上一个cmd的返回值。
exit_status=0
eval ${VCSBIN_DIR}/hvp_exe $cmd ${logout}
exit_status=$?
bash中写一个子标签,
usage()
{
echo "Usages: hvp command"
echo "To see commands, 'hvp help' "
}
bash中的case 。。。esac
case `uname` in
SunOS*)
;;
Linux*)
;;
esac
其中的两个双引号,表示其他语言中的break.
bash中的if-else-fi
if []; then
elif []; then
fi
其中的判断句,-f 存在某个文件;
-x 存在某个可执行文件;
x"${vcs_home}" = x ;判断变量${vcs_home}是否被定义过。前边加x,否则直接应用比较出错。
if [ x"${vcs_home}" = x ]; then
fi
-a,条件与, -o,条件或, !条件非
exit(0) 正常运行程序并退出程序。
exit(1) 非正常运行程序导致退出程序。
shell bash-shell的更多相关文章
- CMD & Git Shell & Bash Shell
CMD & Git Shell & Bash Shell https://mvdan.cc/sh/cmd/shfmt PC
- Linux Shell——bash shell 脚本简介
bash shell 脚本简介 shell 运行环境 如果你运行的是 Unix 或 Linux 系统,例如 Ubuntu,Red Hat,SUSE Linux,还有macOS,都是内置了 bash s ...
- linux shell & bash
shell & bash shell指允许用户通过文本操作计算机的程序. interactive shell:从是否通过标准输入输出与用户进行交互的角度分为交互式shell(interacti ...
- [Bash Shell] Shell学习笔记
1. Shell简介 Shell本身是一个用C语言编写的程序,它是用户使用Unix/Linux的桥梁,用户的大部分工作都是通过Shell完成的.Shell既是一种命令语言,又是一种程序设计语言.作为命 ...
- bash shell
Linux的shell 与windows只有一种批处理脚本不同,由于早年的Unix年代,发展者众,出现了各种不同的distribution,因此也随着不同的distribution出现了各自的shel ...
- 常见linux命令释义(第八天)—— Bash Shell 的操作环境
换了新公司,公司的领导很不错.自己感受比较多的地方是,自己的工作效率明显比以前高了.以前会对频繁变动的需求十分不耐烦,现在接到需求后会仔细的思考,进行整体构建.即使以后需求有变动,也能够比较轻易的在原 ...
- shell,bash,git bash,xshell,ssh
一:shell是linux/unix系统的外壳,也可以理解为命令行接口,就是你输入并执行命令行的地方.bash(born again shell)是shell的一种,最常用的shell之一.你在你的l ...
- Bash Shell内建命令和保留字
Bash Shell内建命令和保留字命令含义!保留字,逻辑非:不做任何事,只做参数展开.读取文件并在shell中执行它alias设置命令或命令行别名bg将作业置于后台运行bind将关键字序列与read ...
- Bash Shell 获取进程 PID
转载地址:http://weyo.me/pages/techs/linux-get-pid/ 导读 Linux 的交互式 Shell 与 Shell 脚本存在一定的差异,主要是由于后者存在一个独立的运 ...
- Bash Shell的操作环境
1.路径与命令查找顺序 基本上,命令运行的顺序可以这样看: 1)以相对/绝对路径执行命令,例如“/bin/ls”或“./ls”; 2)由alias找到该命令来执行; 3)由bash内置的(builti ...
随机推荐
- JTable动态刷新数据
http://www.cnblogs.com/fnlingnzb-learner/p/6025408.html 注意下面几个方法的应用场景,不限于JTable,其他swing组件一样 ———————— ...
- C语言 goto语句
/* goto语句 */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* goto语句也 ...
- Iterator和ListIterator
Iterator和ListIterator主要区别有: 一.ListIterator有add()方法,可以向List中添加对象,而Iterator不能. 二.ListIterator和Iterator ...
- Flask-SQLAlchemy 中多表链接查询(不使用外键)
SQLAlchemy 是一个功能强大的 ORM . Flask-SQLAlchemy 是一个 Flask 插件,它让我们在 Flask 框架中使用 SQLAlchemy 变得更容易. 本篇介绍我在使用 ...
- git报错You are not allowed to force push code to a protected branch on this project
当我们有时候回滚了代码,想强制push到远程仓库的时候, git push origin --force 会报如下错误: You are not allowed to force push code ...
- centos 7 IP不能访问nginx Failed connect to 185.239.226.111:80; No route to host解决办法
服务器环境 centos 7.4 问题描述 1.可以ping通IP ,用IP访问nginx 不能访问,在服务器上curl localhost curl 185.239.226.111可以获得 [ro ...
- vue filter方法-时间格式化
plugins/filter.js import Vue from 'vue' // 时间格式化 // 用法:<div>{{data | dataFormat('yyyy-MM-dd hh ...
- IOS gallery
https://github.com/mengxianliang/XLCardSwitch
- electron+react
yarn create react-app electron-react cd electron-react yarn run eject // 修改react-app打包的路径 / -> ./ ...
- Laravel使用Form(转载)
laravel到了5.1.*以上版本,便没有了illuminate/html类库的支持, 我试着把illuminate/html类库加入了laravel5.2,依然没有用, 但是laravelcoll ...