script 字串比對 - Linux

Table of Contents

想請問各位一下

我有個變數中放一個字串

然後我想判斷這個字串裡面有沒有包涵我要的部份字串

如果有,則接著往下做

目前我是卡在不知道要如何做判斷這個部份

以下是我目前所想到的部份:

#!/bin/bash

for file in $(ls $1*)
do
tmpstring=$(file $file)

if [ $tmpstring ] #目前if內的條件式不知道該如何做
then
......
else
......
fi
done

我目前想做的,就是判斷tmpstring中是否有我要的部份字串

有的話,則做then,否則做else

所以還請各位先進指點一下,謝謝

--

--

All Comments