grep 擷取任意字元的問題 - Linux

Valerie avatar
By Valerie
at 2018-09-07T23:20

Table of Contents

不好意思
這問題 我找很久了 還是找不到

問題是這樣
假如我有一個文字檔
例如:
I wanna leave my footprints on the sands of time Know
there was something that, and something that I left behind
When I leave this world, I'll leave no regrets Leave something to remember,

我想找這行出來
there was something that, and something that I left behind

我下的方式是

cat txt | grep -o "there * that"
這邊* 我想要說可以是任意字串
但grep 任意字元 似乎不是用*
我google很久 有找到一個 \w*
可以表示任意一個字元

但這不符合我的需求
因為我不知道中間的任意字元會有幾個
請問有人有好方法嗎??

謝謝

--
Tags: Linux

All Comments

Zenobia avatar
By Zenobia
at 2018-09-12T16:08
* 代表跟前一個字元一樣, 0~N 個
Joe avatar
By Joe
at 2018-09-17T14:35
cat txt |grep "there .* that"
Steve avatar
By Steve
at 2018-09-22T14:18
然後加 -o 只會從 there 顯示到 that (only-matching)
可以參考一下 regular expression
Connor avatar
By Connor
at 2018-09-26T02:54
regexp 正則表示式和 glob 萬用字元是二種不同的東西,
grep 只支援 regexp 。
Hedy avatar
By Hedy
at 2018-09-28T21:10
參考 「正規表示法」

免驅動 晶片讀卡機

Necoo avatar
By Necoo
at 2018-09-06T22:37
買回來結果不能用,在官網爬文爬半天, 用他給的測試 ccid 的程式測: https://ccid.apdu.fr/#CCID_compliant 有抓到讀卡機。 然後找到支援清單: https://ccid.apdu.fr/ccid/shouldwork.html 搜尋 IT-500U 是顯示 在 git ...

Ubuntu 連線 wifi 容易斷線

Margaret avatar
By Margaret
at 2018-09-06T15:12
※ 引述《Aruma ()》之銘言: : as title : 就是wifi常常過一段時間自己斷掉 : 其實不只是Ubuntu/Fedora/Centos7 都有這樣的情形 : 但在windows上都不會有這樣的情形 : sudo find /sys -name control | grep net : /s ...

在多視窗跑不同指令 tmux 多視窗起始指令

Annie avatar
By Annie
at 2018-09-06T13:24
剛好最近有類似的需求。 tmux在開始就開多視窗並且有起始指令 範例 https://i.imgur.com/4IEMQOa.png 對應的指令, new-session, send-keys, split-window tmux new-session \; \ send-keys and#39; ...

如何在ssh開啟的x window中輸入中文

Jake avatar
By Jake
at 2018-09-06T01:54
有人有辦法在經由ssh開啟的x window內進行中文輸入嗎 ex : 在windows系統下使用mobaXterm,經由ssh連到自己的ubuntu server後,開啟 subline text或是chrome,在裡面用hime或gcin打中文 輸入法測試過都是可以用的(非遠端下),但在ssh連線中的 ...

可上PTT的USB開機隨身碟

Blanche avatar
By Blanche
at 2018-09-05T16:11
您想要有一個極簡的隨身碟,只要插入開機就可以瀏覽PTT嗎? 這裡有一個說明與分享,可製作這樣的隨身碟, 開機後可顯示繁體中文,但只能輸入英文, 網址如下: http://yitao.atwebpages.com P.S. 字型是從網路下載,有點醜,敬請見諒! ...