我有產生與路徑的隨機輸出在它 和命令我需要使用AWK提取此路徑。 路徑總是以開始之前結束相同的模式(讓我們假設它總是與/根開始),但其餘的可以改變使用AWK以匹配PATH開始/根/和字符「
例如:
error reason 05/30/2017 12:18:37 [74575:45687]: "/root/this/is/my/path/" random text random text random text random text random text random text
提取/根/這/是/我的/路徑/:我一直在使用tryed grep + awk的方式如下:
command.sh | grep error |awk '/root/{mypath=$6}'.
但是我後來發現我的路並不總是處在同一個地方。更重要的是,我不想提取雙引號。
i need to have /root/this/is/my/path/ not "/root/this/is/my/path/"
任何人都可以幫忙嗎?
試'的grep -OP「\ d {5}:\ d {5}]:「\ K [ ^「] +'' –