LINUX BASH SHELL,小小学习一下
注意点要注意的:
整数运算一般通过 let 和 expr 这两个指令来实现,如对变量 x 加 1 可以写作:let "x = $x + 1" 或者 x=`expr $x + 1`
两个比较表格要记得:
|
对应的操作 |
整数操作 |
字符串操作 |
|
相同 |
-eq |
= |
|
不同 |
-ne |
!= |
|
大于 |
-gt |
> |
|
小于 |
-lt |
< |
|
大于或等于 |
-ge |
|
|
小于或等于 |
-le |
|
|
为空 |
-z |
|
|
不为空 |
-n |
|
运算符 |
含义( 满足下面要求时返回 TRUE ) |
|
-e file |
文件 file 已经存在 |
|
-f file |
文件 file 是普通文件 |
|
-s file |
文件 file 大小不为零 |
|
-d file |
文件 file 是一个目录 |
|
-r file |
文件 file 对当前用户可以读取 |
|
-w file |
文件 file 对当前用户可以写入 |
|
-x file |
文件 file 对当前用户可以执行 |
|
-g file |
文件 file 的 GID 标志被设置 |
|
-u file |
文件 file 的 UID 标志被设置 |
|
-O file |
文件 file 是属于当前用户的 |
|
-G file |
文件 file 的组 ID 和当前用户相同 |
|
file1 -nt file2 |
文件 file1 比 file2 更新 |
|
file1 -ot file2 |
文件 file1 比 file2 更老 |
#!/bin/bash
#This is a very simple example
STR="Hello , World!"
echo $STR
echo "$STR"
echo '$STR'
echo ${STR}
x=
let "x = $x + 1"
echo $x
x=``
echo $x
x="olympic'"$x
echo $x
HELLO=Hello
function hello {
local HELLO=World
echo $HELLO
}
echo $HELLO
hello
echo $HELLO
~
LINUX BASH SHELL,小小学习一下的更多相关文章
- Linux 下Shell的学习
1.Shell学习 1.什么是Shell shell是一个命令解析器,在操作系统的最外层,负责和用户对话,将用户的输入解释给操作系统,并处理各种各样的操作系统的输出结果.2.什么是shell脚本 ...
- linux BASH shell设置字体与背景颜色
linux BASH shell下设置字体及背景颜色的方法. BASH shell下设置字体及背景颜色 echo -e "\e[31mtest\e[41m" \e[30m 将字 ...
- Linux 下shell 编程学习脚手架
linux body { font-family: Helvetica, arial, sans-serif; font-size: 14px; line-height: 1.6; padding-t ...
- 【Linux】linux bash shell之变量替换::=句法、=句法、:-句法、-句法、=?句法、?句法、:+句法、+句法
linux bash shell之变量替换::=句法.=句法.:-句法.-句法.=?句法.?句法.:+句法.+句法 linux bash shell之变量替换::=句法.=句法.:-句法.-句法. ...
- Linux Bash Shell常用快捷键
Linux Bash Shell常用快捷键 table { margin: auto } 快捷键 功能 tab 补全 ctrl + a 光标回到命令行首 ctrl + e 光标回到命令行尾 ctrl ...
- Linux bash shell All In One
Linux bash shell All In One Linux https://tinylab.gitbooks.io/shellbook/content/zh/chapters/01-chapt ...
- linux bash shell & lsof & grep & ps
linux bash shell & lsof & grep & ps lsof list all open files # lsof & grep $ lsof -P ...
- Linux之bash shell的学习
1.什么是bash shell bash 是Bourne Again Shell的简称,是从unix系统中的sh发展而来,是用户和偶Linux内核交互的工具,用户通过bash操作内核完成系统的使用和 ...
- linux bash shell 流程控制(if/else )
本文转自:http://blog.csdn.net/flowingflying/article/details/5069646 本文也即<Learning the bash Shell>3 ...
- (转)linux bash shell 入门教程
Shell Script(bash)简介 众所皆知地,UNIX上以小工具著名,利用许多简单的小工具,来完成原本需要大量软体开发的工作,这一点特色,使得UNIX成为许多人心目中理想的系统平台. 在众多的 ...
随机推荐
- C# 对JS编码/解码进行转换
public static class Extension { #region [编码/解码统一转换] /// <summary> /// /// </summary> /// ...
- UNDERSTANDING VOLATILE VIA EXAMPLE--reference
We have spent last couple of months stabilizing the lock detection functionality in Plumbr. During t ...
- [转] Java中继承thread类与实现Runnable接口的区别
Java中线程的创建有两种方式: 1. 通过继承Thread类,重写Thread的run()方法,将线程运行的逻辑放在其中 2. 通过实现Runnable接口,实例化Thread类 在实际应用中, ...
- 使用HTML5 WebDataBase设计离线数据库
基于HTML5的Web DataBase 可以让你在浏览器中进行数据持久地存储管理和有效查询,假设你的离线应用程序有需要规范化的存储功能,那么使用Web DataBase,可以使你的应用程序无论是在离 ...
- css.day03.eg
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 【原】push过快的错误 (Pushing the same view controller instance more than once is not supported)
今天在点击按钮push viewController 时,控制台报错: Terminating app due to uncaught exception 'NSInvalidArgumentExce ...
- tableView代理方法的调用时间,(主要是heightForRowAtIndexPath和cellForRowAtIndexPath调用时间)
最近做一个demo,涉及按照数据分类然后依照分类在 cellForRowAtIndexPath形成不同类型的cell,就是有判断(在viewdidload里面做)和形成(在 cellForRowAtI ...
- iOS9 集成指纹解锁
添加依赖库 LocalAuthentication.framework #import <LocalAuthentication/LocalAuthentication.h> // 头文件 ...
- 为你的网页中添加一些空格
在上一节的例子,我们已经讲解过在html代码中输入空格.回车都是没有作用的.要想输入空格,必须写入 . 语法: 在html代码中输入空格是不起作用的,如下代码. 在浏览中显示,还是没有空格效果. ...
- JavaScript 字符串
字符串属性 属性 描述 constructor 返回创建字符串属性属性的函数 length 返回字符串的长度 prototype 允许您向对象添加属性和方法 字符串方法 Method 描述 charA ...