随笔分类 - linux shell
摘要:1、查看系统 [root@centos7pc1 test3]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) [root@centos7pc1 test3]# lsb_release -a LSB Version: :cor
阅读全文
摘要:1、iP清单、脚本 [root@centos7pc1 test2]# ls ip.txt test.sh [root@centos7pc1 test2]# cat ip.txt www.baidu.com xxxxx www.jd.com yyyyy www.sina.com zzzzz 192.1
阅读全文
摘要:1、创建用户列表 [root@centos7pc1 home]# seq -f liujiaxin%02g 2 10 liujiaxin02 liujiaxin03 liujiaxin04 liujiaxin05 liujiaxin06 liujiaxin07 liujiaxin08 liujiax
阅读全文
摘要:1、linux中if条件判断语句,基本结构: if 条件判断语句 then command fi [root@centos7pc1 test2]# ls test.sh [root@centos7pc1 test2]# cat test.sh ## 脚本文件 #!/bin/bash if [ ! -
阅读全文
摘要:1、查看系统中当前的所有用户 [root@centos7pc1 test2]# grep bash /etc/passwd root:x:0:0:root:/root:/bin/bash liujiaxin01:x:1000:1000:liujiaxin01:/home/liujiaxin01:/b
阅读全文
摘要:1、系统 [root@centos7pc1 test2]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-n
阅读全文
摘要:1、逻辑与&&: 在前面语句执行成功时才执行后面的语句 [root@rhelpc1 test]# ls a.txt [root@rhelpc1 test]# wc -l a.txt 0 a.txt [root@rhelpc1 test]# wc -l a.txt && echo OK ## 逻辑与&
阅读全文
摘要:1、 $0: 当前的shell文件名 $#: 一共包含几个参数 $*: 所有的参数 $?:上一步执行的结果,成功执行返回0,不成功执行返回1或其他 $1: 第一个参数 $2:第二个参数 $3: 第三个参数 测试: [root@rhelpc1 test]# ls test.sh [root@rhelp
阅读全文
摘要:1、测试 [root@rhelpc1 test2]# ls [root@rhelpc1 test2]# seq 10 > a.txt [root@rhelpc1 test2]# ls a.txt [root@rhelpc1 test2]# cat a.txt ## 测试数据 1 2 3 4 5 6
阅读全文
摘要:1、行选择 vim file打开文件,在命令模式下输入大写V即可: 按方向键或数字+j/k可以实现行的选择。 2、列选择 vim file打开文件,命令模式下输入ctrl + v即可: 按方向键可以实现列选择。
阅读全文
摘要:1、 删除当前行: dd 删除当前行及向下3行:3dd 或者 d3j 删除当前行及向上3行:d3k 删除当前行及到第1行:d1G 或者 d+gg 删除当前行到最后1行:dG 删除光标所在位置及到行末:d$ 或者D 删除光标所在位置到行首:d0 删除当前字符:x, 相当于delete键 删除当前字符:
阅读全文
摘要:1、Shell 的变量,可以分为“环境变量”和“自定义变量”两种类型,两者的区别在于作用范围不同。环境变量可以在其进程的子进程中继续有效,而自定义变量的势力范围则无法延伸到其进程的子进程中。 [root@localhost test]# ls [root@localhost test]# A=100
阅读全文
摘要:1、直接使用type命令进行判断 [root@localhost test]# type pwd ## pwd是内部命令 pwd is a shell builtin [root@localhost test]# type plink ## plink是外部命令 plink is hashed (/
阅读全文
摘要:1、创建别名命令 [root@localhost test]# pwd /home/test [root@localhost test]# abc bash: abc: command not found... [root@localhost test]# alias abc=pwd ## 创建别名
阅读全文
摘要:双引号“”:不进行转义,保留变量属性。 单引号‘’:进行转义,使其成为单纯的字符串。 [root@localhost test]# A=10 [root@localhost test]# echo $A 10 [root@localhost test]# echo "number is $A" ##
阅读全文
摘要:?:表示匹配任意一个。 *:表示匹配0个或任意多个 [root@localhost test]# ls ab ab1 ab12 ab123 [root@localhost test]# ls -l ab* ## *表示匹配0个或任意多个 -rw-r--r--. 1 root root 0 Mar 2
阅读全文
摘要:1、redhat(centos)中 [root@localhost Desktop]# hostnamectl Static hostname: localhost.localdomain Icon name: computer Chassis: n/a Machine ID: 7dcb3b04ae
阅读全文
摘要:1、标准输出重定向:1>, 1可以省略 root@ubuntu01:/home/test# ls a.txt root@ubuntu01:/home/test# ls -l a.txt -rw-r--r-- 1 root root 6 3月 27 19:52 a.txt root@ubuntu01:
阅读全文
摘要:1、在当前路径直接查找 root@ubuntu01:/home/test# ls 01.txt 02.csv 02.txt 03.csv 04.txt root@ubuntu01:/home/test# find 02.csv 02.csv root@ubuntu01:/home/test# fin
阅读全文
摘要:1、测试数据 root@ubuntu01:/home/test# ls outcome.map outcome.ped root@ubuntu01:/home/test# ll -h total 80M drwxr-xr-x 2 root root 4.0K 3月 27 15:58 ./ drwxr
阅读全文

浙公网安备 33010602011771号