shell中如何比較兩字串是否相等

2021-07-05 06:34:07 字數 687 閱讀 4054

1樓:匿名使用者

#!/bin/bash

a="abc"

b="def"

if [ "$a" = "$b" ]

then

echo " a is same as b"

else

echo "a is different from b"fi

2樓:小米飛貓

#!/bin/bash

#filename is diffs.shif [ $# != 2 ];

then

echo "usage:./diffs.sh text1 text2"

elif [ $1 = $2 ];

then

echo " text1 is same as text2"

else

echo "text1 is different from text2"fi

3樓:

a="string1"

b="string2"

if [ $a = $b ]

then

echo "$a eq $b"

else

echo "$a ne $b"fi

4樓:

shell是什麼意思?是c#語言嗎?

js中如何分離字串,JS中如何分離字串

有兩種方式du 1 通過zhisplit關鍵字進行分離 var str abd,sda,dsad 定義一dao個字串 var arr str.split 通過版逗號把字串分隔。arr 0 等於 權abd,arr 1 等於sda,arr 2 等於dsad2 通過substring的方式進行分割 var...

怎樣向shell函式中傳遞有空格的字串引數

1,2,3,代表第1,第2,第3.個引數 代表引數個數 寫一個指令碼 cat parameter 1.sh bin bash echo 1,2,3 echo 增加執行許可權 chmod x parameter 1.sh執行它,帶3個引數 parameter 1.sh q1 q2 q3q1,q2,q3...

js中如何判斷字串在另字串的多少位

js中如何判斷一個字串在另一個字串的位置,可以直接呼叫indexof方法即可,專如果不存在則會屬返回 1。例如 var a1 abcdefg var a2 ef alert 字串a1 a1 alert 字串a2 a2 alert 字串a2在字串a1的位置 a1.indexof a2 js 是支援很多...