第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問grep只能顯示匹配搜索模式的單詞嗎?

請問grep只能顯示匹配搜索模式的單詞嗎?

白衣非少年 2019-08-02 07:02:39
grep只能顯示匹配搜索模式的單詞嗎?是否有辦法使grep輸出與搜索表達(dá)式匹配的文件中的“單詞”?如果我想在多個文件中找到“th”的所有實例,我可以這樣做:grep "th" *但是輸出將是類似的(粗體是由我);some-text-file : the cat sat on the mat   some-other-text-file : the quick brown fox   yet-another-text-file : i hope this explains it thoroughly使用相同的搜索,我希望它輸出的是:the the the this thoroughly這有可能使用grep嗎?還是使用另一種組合的工具?
查看完整描述

3 回答

?
蕪湖不蕪

TA貢獻(xiàn)1796條經(jīng)驗 獲得超7個贊

試試grep-o

grep -oh "\w*th\w*" *

編輯:與菲爾的評論相匹配

從…醫(yī)生:

-h, --no-filename
    Suppress the prefixing of file names on output. This is the default
    when there is only  one  file  (or only standard input) to search.
-o, --only-matching
    Print  only  the matched (non-empty) parts of a matching line,
    with each such part on a separate output line.




查看完整回答
反對 回復(fù) 2019-08-03
?
炎炎設(shè)計

TA貢獻(xiàn)1808條經(jīng)驗 獲得超4個贊

只是awk不需要工具的組合。

# awk '{for(i=1;i<=NF;i++){if($i~/^th/){print $i}}}' file
the
the
the
this
thoroughly



查看完整回答
反對 回復(fù) 2019-08-03
  • 3 回答
  • 0 關(guān)注
  • 460 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號