第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

以下內(nèi)容是關(guān)于shell if 參數(shù)的,求解釋~

以下內(nèi)容是關(guān)于shell if 參數(shù)的,求解釋~

慕尼黑8549860 2022-01-13 15:11:21
1.如果a>b且a<c,在SHELL里怎么寫(xiě)?是if [ a>b -a a<c ]嗎?2.如果a>b或a<c,在SHELL里怎么寫(xiě)?是if [ a>b -o a<c ]嗎?3.如果a>b或(a<c且a<d)怎么寫(xiě)呢?"-o"是or的意思,"-a"是and的意思嗎?4."||"和"&&"在SHELL里可以用嗎?也就是第一個(gè)寫(xiě)成if [ a>b && a<c ]也可以嗎?在SHELL的if條件里"-eq"和"==""-ne"和"!=""-lt"和"<"等是同一個(gè)意思嗎?這里看的越來(lái)越迷糊了..... 請(qǐng)哪位高手多指點(diǎn)指點(diǎn)!
查看完整描述

2 回答

?
LEATH

TA貢獻(xiàn)1936條經(jīng)驗(yàn) 獲得超7個(gè)贊

1) bash
a=3 ; b=2 ; c=4
if (( a > b )) && (( a < c ))

或者

if [[ $a > $b ]] && [[ $a < $c ]]

或者

if [ $a -gt $b -a $a -lt $c ]

2) a=3 ; b=2 ; c=4

if (( a > b )) || (( a < c ))

或者
if [[ $a > $b ]] || [[ $a < $c ]]

或者
if [ $a -gt $b -o $a -lt $c ]

3) -o = or , -a = and , 但我一向只用 || 或者 &&
4) 可用, 但是要兩個(gè)獨(dú)立的 [ ] , [[ ]] 或 (( ))
看 1)
5) -ne 比較數(shù)字 (numberic) ; != 比較字符 (string), 但后者拿來(lái)
比較數(shù)字也可,只是不是標(biāo)準(zhǔn)用法
-lt 是等同 < , 但 < 只能在 shell 的數(shù)值操作符 (( )) 或
者 邏緝操作符 [[ ]] 才可使用, -lt , -eq , -gt , -ge
-le , 這些是 test , 就是 [ ] 這個(gè)內(nèi)建命令使用的條件操
作符, 數(shù)字用, = , != 字符用, == 這個(gè)該是 [[ ]] 用的,
可用來(lái)比對(duì)正規(guī)表示式, 但用在 [ ] 也可,只是不太正統(tǒng)用法



查看完整回答
反對(duì) 回復(fù) 2022-01-16
?
喵喵時(shí)光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊

不同的shell 有不同的寫(xiě)法,以下是各個(gè)shell的比較:
Feature
C/TC
Bourne
Bash
Korn

Variables:

Assigning values to local variables
set x = 5
x=5
x=5
x=5

Assigning variable attributes

declare or

typeset

typeset

Assigning values to environment variables
setenv NAME Bob
NAME='Bob'; export NAME
export NAME='Bob'
export NAME='Bob'

Read-Only Variables:

Accessing variables

echo $NAME

set var = net

echo ${var}work

network

echo $NAME

var=net

echo ${var}work

network

echo $NAME

var=net

echo ${var}work

network

echo $NAME or print $NAME

var=net

print ${var}work

network

Number of characters
echo $%var (tcsh only)
N/A
${#var}
${#var}

Special Variables:

PID of the process
$$
$$
$$
$$

Exit status
$status, $?
$?
$?
$?

Last background job
$! (tcsh only)
$!
$!
$!

Arrays:

Assigning arrays
set x = ( a b c )
N/A

y[0]='a'; y[2]='b'; y[2]='c'

fruit=(apples pears peaches plums)

y[0]='a'; y[1]='b'; y[2]='c'

set –A fruit apples pears plums

Accessing array elements
echo $x[1] $x[2]
N/A
echo ${y[0]} ${y[1]}
print ${y[0]} ${y[1]}

All elements
echo $x or $x[*]
N/A
echo ${y[*]}, ${fruit[0]}
print ${y[*]}, ${fruit[0]}

No. of elements
echo $#x
N/A
echo $y{#[*]}
print ${#y[*]}

Command Substitution:

Assigning output of command to variable
set d = `date`
d=`date`
d=$(date) or d=`date`
d=$(date) or d=`date`

Accessing values

echo $d

echo $d[1], $d[2],

...

echo $#d

echo $d
echo $d
print $d

Command Line Arguments (Positional Parameters):

Accessing

$argv[1], $argv[2] or

$1, $2 ...

$1, $2 ... $9
$1, $2, ... ${10} ...
$1, $2, ... ${10} ...

Setting positional parameters
N/A

set a b c

set `date`

echo $1 $2 ...

set a b c

set `date` or set $(date)

echo $1 $2 ...

set a b c

set `date` or set $(date)

print $1 $2 ...

No. of command line arguments

$#argv

$# (tcsh)

$#
$#
$#

No. of characters in $arg[number]
$%1, $%2, (tcsh)
N/A
N/A
N/A

Metacharacters for Filename Expansion:

Matches for:

Single character
?
?
?
?

Zero or more characters
*
*
*
*

One character from a set
[abc]
[abc]
[abc]
[abc]

One character from a range of characters in a set
[a–c]
[a–c]
[a-c]
[a–c]

One character not in the set

N/A (csh)

[^abc] (tcsh)

[!abc]
[!abc]
[!abc]

? matches zero or one occurrences of any pattern in the parentheses. The vertical bar represents an OR condition; e.g., either 2 or 9. Matches abc21, abc91, or abc1.
abc?(2|9)1
abc?(2|9)1

Filenames not matching a pattern
^pattern (tcsh)

I/O Redirection and Pipes:

Command output redirected to a file
cmd > file
cmd > file
cmd > file
cmd > file

Command output redirected and appended to a file
cmd >> file
cmd >> file
cmd >> file
cmd >> file

Command input redirected from a file
cmd < file
cmd < file
cmd < file
cmd < file

Command errors redirected to a file
(cmd > /dev/tty)>&errors
cmd 2>errors
cmd 2> file
cmd 2> errors

Output and errors redirected to a file
cmd >& file
cmd > file 2>&1
cmd >& file or cmd &> file or cmd > file 2>&1
cmd > file 2>&1

Assign output and ignore noclobber
cmd >| file
N/A
cmd >| file
cmd >| file

here document

cmd << EOF

input

EOF

cmd << EOF

input

EOF

cmd << EOF

input

EOF

cmd << EOF

input

EOF

Pipe output of one command to input of another command
cmd | cmd
cmd | cmd
cmd | cmd
cmd | cmd

Pipe output and error to a command
cmd |& cmd
N/A
N/A
(See coprocesses)

Coprocess
N/A
N/A
N/A
command |&

Conditional statement

cmd && cmd

cmd || cmd

cmd && cmd

cmd || cmd

cmd && cmd

cmd || cmd

cmd && cmd

cmd || cmd

Reading from the Keyboard:

Read a line of input and store into variable(s)

set var = $<

set var = 'line'

read var

read var1 var2...

read var

read var1 var2...

read

read -p prompt

read -a arrayname

read var

read var1 var2...

read

read var?"Enter value"

Arithmetic:

Perform calculation
@ var = 5 + 1
var=`expr 5 + 1`

(( var = 5 + 1 ))

let var=5+1

(( var = 5 + 1 ))

let var=5+1

Tilde Expansion:

Represent home directory of user
~username
N/A
~username
~username

Represent home directory
~
N/A
~
~

Represent present working directory
N/A
N/A
~+
~+

Represent previous working directory
N/A
N/A
~-
~–

Aliases:

Create an alias
alias m more
N/A
alias m=more
alias m=more

List aliases
alias
alias, alias -p
alias, alias –t

Remove an alias
unalias m
N/A
unalias m
unalias m

History:

Set history
set history = 25
N/A
automatic or HISTSIZE=25
automatic or HISTSIZE=25

Display numbered history list
history
history, fc -l
history, fc –l

Display portion of list selected by number
history 5
history 5

history 5 10

history –5

Re-execute a command

!! (last command)

!5 (5th command)

!v (last command starting with v)

!! (last command)

!5 (5th command)

!v (last command starting with v)

r (last command)

r5 (5th command)

r v (last command starting with v)

Set interactive editor
N/A (csh)

bindkey -v

or bindkey -e (tcsh)
N/A

set -o vi

set -o emacs

set -o vi

set -o emacs

Signals:

Command
onintr
trap
trap
trap

Initialization Files:

Executed at login
.login
.profile
.bash_profile
.profile

Executed every time the shell is invoked
.cshrc
N/A
BASH_ENV=.bashrc (or other filename) (bash 2.x)

ENV=.bashrc
ENV=.kshrc (or other filename)

Functions:

Define a function
N/A
fun() { commands; }
function fun { commands; }
function fun { commands; }

Call a function
N/A

fun

fun param1 param2 ...

fun

fun param1 param2 ...

fun

fun param1 param2 ...

Programming Constructs:

if conditional

if ( expression ) then

commands

endif

if { ( command ) } then

commands

endif

if [ expression ]

then

commands

fi

if command

then

commands

fi

if [[ string expression ]]

then

commands

fi

if (( numeric expression ))

then

commands

fi

if [[ string expression ]]

then

commands

fi

if (( numeric expression ))

then

commands

fi

if/else conditional

if ( expression ) then

commands

else

commands

endif

if command

then

commands

else

...

fi

if command

then

commands

else

...

fi

if command

then

commands

else

...

fi

if/else/elseif conditional

if (expression) then

commands

else if (expression) then

commands

else

commands

endif

if command

then

commands

elif command

then

commands

else

commands

fi

if command

then

commands

elif command

then

commands

else

commands

fi

if command

then

commands

elif command

then

commands

else

commands

fi

goto

goto label

...

label:

N/A
N/A
N/A

switch and case

switch ("$value")

case pattern1:

commands

breaksw

case pattern2:

commands

breaksw

default:

commands

breaksw

endsw

case "$value" in

pattern1) commands

;;

pattern2) commands

;;

*) commands

;;

esac

case "$value" in

pattern1) commands

;;

pattern2) commands

;;

*) commands

;;

esac

case "$value" in

pattern1) commands

;;

pattern2) commands

;;

*) commands

;;

esac

Loops:

while

while (expression)

commands

end

while command

do

command

done

while command

do

command

done

while command

do

commands

done

for/foreach

foreach var (wordlist)

commands

end

for var in wordlist

do

commands

done

for var in wordlist

do

commands

done

for var in wordlist

do

commands

done

until
N/A

until command

do

commands

done

until command

do

commands

done

until command

do

commands

done

repeat

repeat 3 "echo hello"

hello

hello

hello

N/A
N/A
N/A

select
N/A
N/A

PS3="Please select a menu item"

select var in wordlist

do

commands

done



查看完整回答
反對(duì) 回復(fù) 2022-01-16
  • 2 回答
  • 0 關(guān)注
  • 173 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)