当前位置: 首页>编程语言>正文

bash调用javascript bash scripting

本文为Bash Scripting Full Course 3 Hours学习笔记
(此基础上补充)

(base) lighthouse@VM-8-2-ubuntu:~$ cat /etc/shells  # 所有可用shell
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/usr/bin/tmux
/usr/bin/screen

(base) lighthouse@VM-8-2-ubuntu:~$ which bash
/usr/bin/bash

多行注释和多行提示

多行注释 invisible

多行提示 visible

bash调用javascript bash scripting,bash调用javascript bash scripting_bash,第1张

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_02,第2张


条件语句

bash调用javascript bash scripting,bash调用javascript bash scripting_bash调用javascript_03,第3张

注意

① 前后空格

②$

③ [-eq -gt -lt] 等同于((= > <))

le小于等于<=

④[] && || [] 等同于 (()) && || (()) 等同于 括号(([ -a -o 反括号

习惯语句:

<<BLOCK
if [ $count -eq 10 ]
then
        echo 'T'
else
        echo 'F'
fi
BLOCK

if (( $count > 7 )) && (( $count < 12))
then
        echo 'T'
elif (( $count > 29)) || (( $count < 3))
then
        echo 'T`'
else
        echo 'F'
fi

循环

while until

for

bash调用javascript bash scripting,bash调用javascript bash scripting_linux_04,第4张

for

if break/continue

bash调用javascript bash scripting,bash调用javascript bash scripting_linux_05,第5张

(( = ))

attempted assignment to non-variable

? ((==))


bash脚本输入

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_06,第6张

bash调用javascript bash scripting,bash调用javascript bash scripting_linux_07,第7张

bash调用javascript bash scripting,bash调用javascript bash scripting_bash调用javascript_08,第8张

NB: $ 在变量操作括号外 如 n=$(n-1) echo ${args[1]}

按行读取文件

bash调用javascript bash scripting,bash调用javascript bash scripting_linux_09,第9张

Bash读取文件read 内部命令被用来从标准输入读取单行数据。这个命令可以用来读取键盘输入,当使用重定向的时候,可以读取文件中的一行数据。


bash脚本输出

bash调用javascript bash scripting,bash调用javascript bash scripting_bash调用javascript_10,第10张


export

send output from one script to another script

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_11,第11张

bash调用javascript bash scripting,bash调用javascript bash scripting_bash调用javascript_12,第12张

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_13,第13张


字符串操作

区别于前 数值操作

bash调用javascript bash scripting,bash调用javascript bash scripting_读取文件_14,第14张

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_15,第15张

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_16,第16张


数值操作

bash调用javascript bash scripting,bash调用javascript bash scripting_bash调用javascript_17,第17张

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_18,第18张


声明变量

declare

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_19,第19张

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_20,第20张

对变量进行限制


Arrays

联系前面bash脚本输入array

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_21,第21张

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_22,第22张


函数

bash调用javascript bash scripting,bash调用javascript bash scripting_linux_23,第23张

函数构造形式类似R

bash中变量输入通过输入位次来决定 $1 $…


发送邮件

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_24,第24张

我在想是否在每次nohup & 结束后通过邮件把log发给我自己

值得探索


web文件下载

curl

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_25,第25张

curl 和Wget功能比较

professional menu

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_26,第26张

交互选择 select opttion + case loop

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_27,第27张

交互“按任意键退出” read -t -3 -n 1 # -t每三秒 -n 参数设置 read 命令计数输入的字符


inotify

bash调用javascript bash scripting,bash调用javascript bash scripting_linux_28,第28张

监控目录文件夹行为


grep、awk、sed

Linux笔记丨三剑客是谁?grep、sed、awk

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_29,第29张

(注意read 可读取整行输入 且不需$ 如$1 $2等)awk像一门单独的编程语言

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_30,第30张

sed

bash调用javascript bash scripting,bash调用javascript bash scripting_开发语言_31,第31张


debug

bash调用javascript bash scripting,bash调用javascript bash scripting_bash_32,第32张

bash调用javascript bash scripting,bash调用javascript bash scripting_bash调用javascript_33,第33张


https://www.xamrdz.com/lan/5n31967318.html

相关文章: