随笔分类 -  Shell

摘要:1 if 判断 1)基本语法 (1)单分支 if [ 条件判断式 ];then 程序 fi 或者 if [ 条件判断式 ] then 程序 fi 注意事项: ①[ 条件判断式 ],中括号和条件判断式之间必须有空格 ②if 后要有空格 1)案例实操 输入一个参数,如果该参数是xixi 则输出 welc 阅读全文
posted @ 2022-08-14 21:29 KwFruit 阅读(71) 评论(0) 推荐(0)
摘要:1.基本语法 [ condition ](注意condition前后要有空格)注意:条件非空即为true,[ atguigu ]返回true,[] 返回false。 2. 常用判断条件 (1)两个整数之间比较 = 字符串比较-lt 小于(less than) -le 小于等于(less equal) 阅读全文
posted @ 2022-08-14 13:29 KwFruit 阅读(69) 评论(0) 推荐(0)
摘要:1 $n 1)基本语法 $n (功能描述:n 为数字,$0 代表该脚本名称,$1-$9 代表第一到第九个参数,十以 上的参数,十以上的参数需要用大括号包含,如${10}) 2)案例实操 [root@centos7 sh]# touch parameter.sh [root@centos7 sh]# 阅读全文
posted @ 2022-08-07 15:54 KwFruit 阅读(80) 评论(0) 推荐(0)
摘要:变量 1 系统预定义变量 1)常用系统变量 $HOME、$PWD、$SHELL、$USER 等 2)案例实操 (1)查看系统变量的值 [root@centos7 sh]# echo HOME HOME (2)显示当前 Shell 中所有变量:set [root@centos7 sh]# set BA 阅读全文
posted @ 2022-08-07 15:39 KwFruit 阅读(80) 评论(0) 推荐(0)
摘要:1)脚本格式 脚本以#!/bin/bash 开头(指定解析器) 2)第一个 Shell 脚本:helloworld.sh (1)需求:创建一个 Shell 脚本,输出 helloworld (2)案例实操: [root@centos7 sh]$ touch helloworld.sh [root@c 阅读全文
posted @ 2022-08-07 15:32 KwFruit 阅读(601) 评论(0) 推荐(0)
摘要:Shell 概述 1)Linux 提供的 Shell 解析器有 [root@centos7 ~]# cat /etc/shells /bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash /usr/sbin/nologin /bin/tcs 阅读全文
posted @ 2022-08-07 15:27 KwFruit 阅读(41) 评论(0) 推荐(0)