linux的shell脚本if判断有哪些参数?

linux的shell脚本if判断有哪些参数?,第1张

linux 里有很多文档可以帮助学习!

比如

GNU bash, version 3.2.33(1)-release (i386-redhat-linux-gnu)

These shell commands are defined internally. Type `help' to see this list.

Type `help name' to find out more about the function `name'.

Use `info bash' to find out more about the shell in general.

Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

JOB_SPEC [&] (( expression ))

. filename [arguments] :

[ arg... ] [[ expression ]]

alias [-p] [name[=value] ... ] bg [job_spec ...]

bind [-lpvsPVS] [-m keymap] [-f fi break [n]

builtin [shell-builtin [arg ...]] caller [EXPR]

case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir]

command [-pVv] command [arg ...] compgen [-abcdefgjksuv] [-o option

complete [-abcdefgjksuv] [-pr] [-o continue [n]

declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N]

disown [-h] [-ar] [jobspec ...]echo [-neE] [arg ...]

enable [-pnds] [-a] [-f filename] eval [arg ...]

exec [-cl] [-a name] file [redirec exit [n]

export [-nf] [name[=value] ...] or false

fc [-e ename] [-nlr] [first] [last fg [job_spec]

for NAME [in WORDS ... ] do COMMA for (( exp1exp2exp3 ))do COM

function NAME { COMMANDS } or NA getopts optstring name [arg]

hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern ...]

history [-c] [-d offset] [n] or hi if COMMANDSthen COMMANDS[ elif

jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si

let arg [arg ...] local name[=value] ...

logout popd [+N | -N] [-n]

printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]

pwd [-LP] read [-ers] [-u fd] [-t timeout] [

readonly [-af] [name[=value] ...] return [n]

select NAME [in WORDS ... ] do CO set [--abefhkmnptuvxBCHP] [-o opti

shift [n] shopt [-pqsu] [-o long-option] opt

source filename [arguments]suspend [-f]

test [expr]time [-p] PIPELINE

times trap [-lp] [arg signal_spec ...]

true type [-afptP] name [name ...]

typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit

umask [-p] [-S] [mode] unalias [-a] name [name ...]

unset [-f] [-v] [name ...] until COMMANDSdo COMMANDSdone

variables - Some variable names an wait [n]

while COMMANDSdo COMMANDSdone { COMMANDS }

good luck

1 if [-d $1]

这个的意思是 从外面传一个参数给$1 -d是判断$!这个目录存不存在

所以你要穿的参数如果是正确的文件目录名,则此时的判断值为0 即真

2 帮你拓展下:

[ -f 判断参数 ] 判断一个普通文件是不是存在

[ -s 文件名 ] 文件存在且内容非空 即必须要一个空格以上的字符

[ -e文件目录 ] 文件目录下是否不为空


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7346696.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存