随笔分类 - linux shell
摘要:1、linux系统中useradd命令用于创建新的用户 使用方法 useradd name [root@linuxprobe home]# ls linuxprobe software [root@linuxprobe home]# pwd ##路径 /home [root@linuxprobe h
阅读全文
摘要:1、crontab命令用于创建系统能够周期性、有规律地执行某些具体的任务 直接测试:crontab -e 进行创建、编辑任务 [root@linuxprobe test]# ls ## 查看测试文件 a.txt [root@linuxprobe test]# ll -h total 6.6M -rw
阅读全文
摘要:1、一次性计划任务服务顾名思义只执行一次,直接测试 [root@linuxprobe test]# date ## 查看系统当前日期 Mon Oct 19 12:45:10 CST 2020 [root@linuxprobe test]# at 12:48 ## 使用格式, at + 时间,表示在1
阅读全文
摘要:1、case命令选择执行 [root@linuxprobe test]# ls test.sh [root@linuxprobe test]# cat test.sh ## 查看脚本 #!/bin/bash echo "This is a test!" echo "you can choose 0-
阅读全文
摘要:1、 [root@linuxprobe test]# ls ## 测试数据 a.txt [root@linuxprobe test]# cat a.txt fd gfd fgd fsdafds dfs sff [root@linuxprobe test]# cat -A a.txt ^I^Ifd g
阅读全文
摘要:1、测试数据 [root@linuxprobe test]# ls ## 测试数据 a.txt [root@linuxprobe test]# cat a.txt fd gfd fgd fsdafds dfs sfa [root@linuxprobe test]# cat -A a.txt fd g
阅读全文
摘要:1、linux系统中find命令主要用于查找文件,可以设置不同的查找条件进行查找 创建测试数据: [root@linuxprobe test]# touch a.txt b.txt c.txt ## 创建三个普通文件 [root@linuxprobe test]# mkdir test1 test2
阅读全文
摘要:1、linux系统中字符串比较语句用来判断字符串是否相等、或者字符串的代表的变量是否被赋值过 = 表示字符串是否相同 [root@linuxprobe test]# a=xxx [root@linuxprobe test]# [ $a = "xxx" ] [root@linuxprobe test]
阅读全文
摘要:1、-eq 表示等于 [root@linuxprobe test]# [ 3 -eq 4 ] [root@linuxprobe test]# echo $? 1 [root@linuxprobe test]# [ 3 -eq 3 ] [root@linuxprobe test]# echo $? 0
阅读全文
摘要:1、查看系统、java安装情况 [root@linuxprobe ~]# cat /etc/system-release Red Hat Enterprise Linux release 8.0 (Ootpa) [root@linuxprobe ~]# java bash: java: comman
阅读全文
摘要:1、查看系统版本及当前java环境 [root@linuxprobe home]# cat /etc/system-release ## 查看系统版本 Red Hat Enterprise Linux release 8.0 (Ootpa) [root@linuxprobe home]# java
阅读全文
摘要:1、系统版本、java环境查看 [root@linuxprobe home]# cat /etc/system-release ## 查看系统版本 Red Hat Enterprise Linux release 8.0 (Ootpa) [root@linuxprobe home]# java ##
阅读全文
摘要:1、linux系统中case主要用于选择执行、在需要进行多重分支的情况下使用,case在多个范围内匹配数据,若匹配成则执行相关的命令并结束整个条件测试。 简单示例: [root@linuxprobe test]# ls test.sh [root@linuxprobe test]# cat test
阅读全文
摘要:1、&& 表示与,上一句执行成功则执行下一句;|| 表示或,上一句执行失败则执行下一句 [root@linuxprobe test]# touch a.txt [root@linuxprobe test]# ls a.txt [root@linuxprobe test]# [ -e a.txt ]
阅读全文
摘要:1、Linux系统中文件测试语句用于判断文件是否存在、是文件或者目录、或者权限判断 linux系统中 echo $? 用于判断上一句是否成功执行,成功返回0,不成功返回其他数字, 简单示例: [root@linuxprobe test]# ls [root@linuxprobe test]# mkd
阅读全文
摘要:1、linux系统中while循环示例 [root@linuxprobe test]# ls test.sh [root@linuxprobe test]# cat test.sh #!/bin/bash echo "the scale of price is 0-999!" ## 输入内容提示 P
阅读全文
摘要:1、linux中$random用于生成0—32767的随机数 简单示例: [root@linuxprobe r_toy_par]# echo $RANDOM ## 取随机值 (小概率一样) 23603 [root@linuxprobe r_toy_par]# echo $RANDOM ##同上 16
阅读全文
摘要:1、linux系统中let命令在bash中用于计算,变量名前不用加$,可以实现自加和自减操作 简单用法 [root@linuxprobe test]# a=3 [root@linuxprobe test]# echo $a 3 [root@linuxprobe test]# b=a+4 [root@
阅读全文
摘要:1、linux系统中expr命令实现命令行中的四则运算 简单示例: [root@linuxprobe test]# expr 5 + 3 ## 在命令行中实现加法运算 8 2、中间必须有空格 [root@linuxprobe test]# expr 5+3 ##中间必须有空格 5+3 [root@l
阅读全文
摘要:1、linux系统中read命令用于从标准输入中读取数据,进而给变量赋值。 简单用法: [root@linuxprobe test]# echo $var1 ## 首先查看未赋值前变量,发现是空值 [root@linuxprobe test]# read var1 ## read命令直接跟想要赋值的
阅读全文