關於正規表示 - Linux

David avatar
By David
at 2015-01-15T11:37

Table of Contents

板友好

有一個檔案 tunnel_list 內容為

tunnel1
tunnel2
tunnel3


我寫了一個 script: remove_tunnel.sh 內容為

#!/bin/bash

sed -i 's/$1//g' tunnel_list
sed -i '/^$/d' tunnel_list



並在 shell 中丟入參數

./remove_tunnel.sh tunnel1


它無法刪除 tunnel1,因為$在sed中好像代表句尾,請問我參數1在 sed 中
要怎表示呢? 謝謝


--
Tags: Linux

All Comments

Irma avatar
By Irma
at 2015-01-17T07:47
改成 sed -i "s/$1//g" tunnel_list 應該就可以了
Charlotte avatar
By Charlotte
at 2015-01-20T02:47
謝謝。可以了..謝謝
Dorothy avatar
By Dorothy
at 2015-01-23T06:07
有 regexp 板喔~
Christine avatar
By Christine
at 2015-01-27T13:56
這是跟linux相關的,因為shell不會expand單引號裡的變數
Hedy avatar
By Hedy
at 2015-01-31T06:36
嗯嗯 習慣性推廣,雖然我早已沒逛那板XD

docker 的port mapping

Anthony avatar
By Anthony
at 2015-01-14T17:00
各位大大好 想請教有人使用過docker的port mapping嗎? 一般來說我們的port最高到65535個, 並且剔除一些server/PC 的預留port, 可能還剩下6萬多個 小弟一直很困惑如果local主機建立的docker container, 所使用的port數超過6萬多個 也就是說把 ...

現在你可以下載北韓優質作業系統紅星3.0

Lydia avatar
By Lydia
at 2015-01-14T15:44
你自己玩過嗎? http://minus.com/mhkl82Un4Qkmf http://minus.com/i/J38gp3TAeY1j all 韓文 ※ 引述《Kitakami (北上)》之銘言: : 標題不知道怎麼下 所以就照國外的翻譯模式下了(誤) : 先前新聞有報導過了 : 曾經在Googl ...

skype字太小 ubuntu 14.04

Connor avatar
By Connor
at 2015-01-14T12:31
解決方法 sudo apt-get install qt4-qtconfig 執行 qt4-qtconfig 可設定字型大小 - ...

evernote取代方案 ubuntu14.04

Callum avatar
By Callum
at 2015-01-14T11:29
若要裝原生Evernote 用wine sudo add-apt-repository ppa:ubuntu-wine/ppa sudo apt-get update sudo apt-get install wine1.7 winetricks https://evernote.com/downlo ...

QQ 於 Ubunutu 14.04

Edith avatar
By Edith
at 2015-01-14T11:24
因為工作的關係 QQ是必備的軟體 如果使用的是64位系统,先安装ttf-wqy-microhei。 安裝完畢後 進行下述指令 wget http://ftp.vim.org/os/Linux/distr/deepin/pool/non-free/d/deepinwine-qqintl/deepinwi ...