System variable.
Option
|
Function
|
$abc
${abc}
|
|
$(command)
|
|
$?
|
|
$n
|
|
$#
|
|
$0
|
Program name.
|
$*
|
Store all argument with “arg1 arg2 …”
|
$@
|
Store all argument with “arg1” “arg2” …
|
Note: If using in “…”, add {}, e.g. “… ${0} …”
User variable
e.g. name="Winter" echo $name
Environment variable
e.g. PATH, LOGNAME (logon user name)…
{}
Concatenate variable and string. E.g. SAT=Satur echo ${SAT}day
Unset
Clean variable. E.g. unset a
readonly
Content of variable can’t be changed. E.g. readonly a=2;unset a;echo “a=$a”;
array
e.g. name[0]=”a”;name[1]=”b”; echo ${name[$i]};
typeset [options] [variable[=value ...]]
Korn shell only. Assign a type to each variable. -option enables the type and +option disables it.
argument
|
Function
|
i
|
|
(nil)
|
|
e.g.
typeset +r PWD End read-only status of PWD.
let expressions
or
((expressions))
Korn shell only. Specified by one or more integer expressions which consist of numbers, operators, shell variables. Expressions must be quoted if they contain spaces.
e.g.
i=`expr $i + 1`
let i=i+1
let "i = i + 1"
(( i = i + 1 ))
let $a + $b
while [condition] (or [[ … ]])
do
…
done (or done < InputFile)
|
for string in list
do
…
done
|
if / elif [condition] (or [[ … ]])
then
…
(else)
…
fi
|
Operation in control statement
Operator
[[ ]]
-a file
-d file
-e file
-f file
-r file
-s file
-w file
-x file
-O file
-G file
1 -nt 2
1 -ot 2
-lt
!=, >, <
-n str
-z str
&&,||,-a,-o
|
True if...
It is better integrated into the Korn shell, it provides many options to check different attributes of a file, returns an exit status.
True if the file exists.
file is a directory
True if the file exists.
file is a regular file (i.e., not a directory or other special type of file)
You have read permission on file
file exists and is not empty
You have write permission on file
You have execute permission on file, or directory search permission if it is a directory
You own file
Your group ID is the same as that of file
file1 is newer than file2
file1 is older than file2
Less than (other like -le, -eq, -ge, -gt, -ne)
Normal compare.
Str is not null (length greater than 0).
Str is null (length is 0).
Seems same as and (&&) or (||).
|
Other
break
|
Exit from a while or for loop.
|
continue
|
|
exit
|
|
return [expr]
|
|
e.g.
if [[ -f "$ldcmd" ]]
then
while read LINE
do
…
Done < ${ldcmd}
fi
rc=$?
return ${rc}
if command && [[ condition_1 || condition_2 ]]; then …
while [ $hour -le 0030 -o $hour -ge 2200 ]
function function_name () {commands; commands; }
unset -f function_name
Ø Break line: ( backslash \ )
Ø Concatenate string: ( blank )
分享到:
相关推荐
14. `tlist` 和 `kill`:这两个命令是用于查看和结束进程的,通常在系统调试和故障排除中使用。 15. `del` 和 `move`:文件管理命令,`del`用于删除文件,`/S /Q`选项可以递归删除目录及其内容而不提示,`move`用于...
隐藏 CMD 黑窗口的脚本通常用于在运行批处理文件或其他命令行程序时,避免显示命令提示符窗口,这样可以让用户在后台执行脚本而不会干扰到其他任务。 该文件需配合BAT脚本使用,在.vbs中将路径指向BAT脚本并运行该...
如`dir /b | sort > list.txt` 会排序目录中的文件并保存到`list.txt`,然后可以使用`fc /l list.txt list_sorted.txt` 比较排序前后的差异。 3. **统计分析**:`find`命令可以计数特定字符或字符串。如`type file....
List<String> commands = Arrays.asList("cmd", "/c", "dir"); ProcessBuilder pb = new ProcessBuilder(commands); Process process = pb.start(); ``` **JavaScript调用命令行** 在JavaScript中,由于安全...
* -L [ c ] list servers [ clean output ]:列出服务器。 * -p [ 1 ] print statistics [ colon format ]:打印统计信息。 * -X [ 1 ]:禁用命令、启动脚本和环境变量。 * -? show syntax summary:显示语法摘要。 ...
##### 9. **`net send`** - **向其他计算机发送消息**: ```cmd net send IP 文本信息 ``` 向指定IP地址的计算机发送文本消息。 ##### 10. **`net ver`** - **查看局域网内的网络连接类型和信息**: ```...
在压缩包内的`Test-cmd`和`build-Test-cmd-Desktop_Qt_5_9_3_MSVC2015_64bit-Debug`文件夹中,`Test-cmd`很可能是源代码目录,包含Qt项目的主文件和相关源码,而`build-...`目录是使用CMake构建生成的临时目录,包含...
process.start("cmd.exe", QStringList() ); process.waitForFinished(); ``` 这里的`start`方法启动了CMD进程,并通过`/c`参数传递了执行"dir"命令的指令。`waitForFinished`确保我们等待命令执行完成后再继续执行...
6. `perl-Module-CoreList-2.76.02-299.el7_9.noarch.rpm`: 显示Perl核心模块的版本信息,帮助确定哪些模块已经包含在当前Perl版本中。 7. `perl-version-0.99.07-6.el7.x86_64.rpm`: 为Perl处理版本号提供支持,...
### CMD中的重定向输出与管道操作详解 在日常的编程工作中,特别是在Windows环境下进行开发时,熟练掌握CMD命令行工具的使用技巧对于提高工作效率是非常有帮助的。本文将重点介绍CMD中的重定向输出(`>`、`>>`)...
2. **事件选择**: `trace-cmd list`可以列出所有可用的内核事件,用户可以根据需求选择要追踪的事件。 3. **查看日志**: `trace-cmd report`命令将追踪数据转化为可读的报告,帮助分析系统行为。 4. **保存/加载**...
cmd.Parameters.Add(new OracleParameter("p_list", oraArray)); cmd.ExecuteNonQuery(); ``` 5. **关闭连接**: 执行完存储过程后,别忘了关闭数据库连接。 通过这种方式,C#中的自定义列表(List)可以高效地...
### 遍历CheckBoxList,获得选中项的值动态绑定CheckBoxList #### 知识点一:CheckBoxList概述及应用场景 **CheckBoxList** 是ASP.NET Web Forms中一个非常有用的控件,它允许用户选择一个或多个选项。CheckBoxList...
- `tlist`:显示系统中的进程。 - `kill`:结束进程。 - `route print`:显示路由表。 这些CMD命令涵盖了从基础的文件操作到复杂的网络管理,是IT专业人员必备的技能之一。熟练掌握它们,可以极大地提高工作效率...
在Java编程中,有时我们需要执行一些系统级别的操作,如创建目录、复制文件等,这些操作在Windows系统中可以通过命令行接口(CMD)来完成。Java提供了Runtime类和ProcessBuilder类来实现这样的功能,允许我们调用...
* firewall-cmd --zone=dmz --list-ports 这将显示 dmz zone 中所有打开的端口。 firewall-cmd 命令还可以用于添加端口到 zone,例如: * firewall-cmd --zone=dmz --add-port=8080/tcp 这将添加 8080 端口到 ...
16. `tlist -t`和`kill -F`: 分别用于列出和结束进程,通常在Support Tools中。 17. `del`和`rmdir`: 用于删除文件和目录,`-F`选项可删除只读文件,`/S`和`/Q`分别用于删除目录及其内容,且不提示确认。 18. `...
- `tlist -t`:列出系统进程(需额外安装工具)。 - `kill -F`:强制结束进程(同样需要额外安装工具)。 掌握这些CMD命令,可以帮助用户高效地进行系统管理和网络操作,尤其是在没有图形用户界面的情况下。了解...