Shell Script 中 Regular Expression - Linux

By Edith
at 2008-11-21T15:31
at 2008-11-21T15:31
Table of Contents
※ 引述《godman362 (Shizuru)》之銘言:
: 我是最近才開始寫shell script
: 所以若是問題太過簡單還請各位見諒
: 我想在script中用if去判斷輸入的檔案名稱的副檔名
: 在根據副檔名做不同的處理
: 我目前大概是這樣想的,大致如下:
: if [ $1 =~ [a-zA-Z]\.cpp ]; then
: echo "CPP"
: fi
extension=`echo $1 | cut -d "." -f 2`
if [ $extension == "cpp" ]; then
echo "CPP"
fi
: 但是判別出來一直是錯誤的
: 所以想請教一下,該如何在if判斷句中做修正
--
Appleboy Blog: http://blog.Wu-Boy.com
Appleboy Life: http://life.wu-boy.com
--
: 我是最近才開始寫shell script
: 所以若是問題太過簡單還請各位見諒
: 我想在script中用if去判斷輸入的檔案名稱的副檔名
: 在根據副檔名做不同的處理
: 我目前大概是這樣想的,大致如下:
: if [ $1 =~ [a-zA-Z]\.cpp ]; then
: echo "CPP"
: fi
extension=`echo $1 | cut -d "." -f 2`
if [ $extension == "cpp" ]; then
echo "CPP"
fi
: 但是判別出來一直是錯誤的
: 所以想請教一下,該如何在if判斷句中做修正
--
Appleboy Blog: http://blog.Wu-Boy.com
Appleboy Life: http://life.wu-boy.com
--
Tags:
Linux
All Comments
Related Posts
ld的問題

By Megan
at 2008-11-21T12:41
at 2008-11-21T12:41
如何將window裡的IE網頁備份到linux的書籤

By Ula
at 2008-11-21T11:20
at 2008-11-21T11:20
如何將window裡的IE網頁備份到linux的書籤

By Ivy
at 2008-11-21T10:56
at 2008-11-21T10:56
有沒有都是小遊戲的distribution?

By Harry
at 2008-11-21T10:11
at 2008-11-21T10:11
archlinux

By Eartha
at 2008-11-21T01:01
at 2008-11-21T01:01