echo "$a : The string is not empty" else echo "$a : The string is empty" fi 结果 abc = efg: a != b -n abc : The string length is not 0 abc : The string is not empty 文件测试运算符 实例: #!/bin/bash file="/home/shiyanlou/test.sh" if [ -r $file ] then echo "The ...
Ctrl+l=》清屏 等价clear Ctrl+a=》快速跳到行首 Ctrl+e=》快速跳到行尾 Alt+.=》引用上一个命令的最后一个参数(只能在VMware里面使用),等价于!$ 历史命令 代码语言:javascript 代码运行次数:0 运行 AI代码解释 // 1.查看历史命令[root@xxx~]# history // 2.清空历史命令[root@xxx~]# history-c// ...
find.-type f!-perm/a+w # 找出你帐号主目录下的所有可执行文件 find~-type f-perm/a+w # 找出/tmp 目录下的.log文件并将其删除: find/tmp/-type f-name"*.log"-exec rm-f{}\;# 找出当前目录下的所有空文件 find.-type f-empty # 找出当前目录下的所有空目录 find.-type d-empty # 找出/t...
#使用格式:[命令] + [--help] 或者[man] + [命令] 即可#例如touch命令帮助[root@CentOS7 ~]# touch --helpUsage: touch [OPTION]... FILE...Update the access and modification times of each FILE to the current time.A FILE argument that does not exist is created empty, unless -c or -hi...
rmdir命令用于删除一个空的目录。例如,rmdir empty_directory将删除名为empty_directory的空目录。 (6) cp命令:复制文件和目录 cp命令用于复制文件或目录。例如,cp myfile newfile将文件myfile复制为newfile。 (7) mv命令:移动文件和目录 mv命令用于移动文件或目录。例如,mv myfile new_location将文件myfile移动到...
grep pattern filename 1. Example: $ grep admin /etc/passwd _kadmin_admin:*:218:-2:Kerberos Admin Service:/var/empty:/usr/bin/false _kadmin_changepw:*:219:-2:Kerberos Change Password Service:/var/empty:/usr/bin/false _krb_kadmin:*:231:-2:Open Directory Kerberos Admin Service:/var/emp...
cat file.txt: 输出文件内容到标准输出设备(屏幕)上 file somefile: 得到文件类型 read var: 提示用户输入,并将输入赋值给变量 sort file.txt: 对file.txt文件中的行进行排序 uniq: 删除文本文件中出现的行列比如: sort file.txt | uniq expr: 进行数学运算Example: add 2 and 3expr 2 "+" 3 ...
1: > data.xxx # File "data.xxx" now empty.等价于 cat /dev/null >data.xxx如果以追加方式的重定向,则对文件不构成任何修改。同样如果文件不存在也会新建一个。例如 : >> data.xxx 。注意 这个只能在普通文件中使用,不能在管道,符号链接和其他特殊文件中使用;你也可以作为域分隔符,比如环境变量$...
Bash 简介 转自 https://wangdoc.com/bash/intro.html Bash 是 Unix 系统和 Linux 系统的一种 Shell(命令行环境),是目前绝大多数 Linux 发行版的默认 Shell。 目录 [隐藏] 简介 基本语法 模式扩展 引号和转义 变量 字符串操
A FILE argument that does not exist is created empty, unless -c or -h is supplied. A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard output. Mandatory arguments to long options are mandatory for short options too. ...