我正在尋找最簡單的方法來替換\ n字符,但僅限於包含特定表達式的給定行。僅在包含字符串/表達式的行上使用命令行工具刪除換行符
輸入看起來像這樣
00:03:04
text alphabetic abcde
00:03:08
text alphabetic abcde
00:03:17
text alphabetic abcde
00:03:26
text alphabetic abcde
輸出會像
00:03:04 text alphabetic abcde
00:03:08 text alphabetic abcde
00:03:17 text alphabetic abcde
00:03:26 text alphabetic abcde
現在我想更換成\ n僅在非字母線。
我想最簡單的方法是'tr',但我看不出如何限制到指定的行。
我用sed擺弄,但這似乎相當成問題。
我不敢相信沒有一種優雅的方式來說 「以[0-9] [0-9]:」開頭的行代替換行符。
你會怎麼做呢?
男人,這是完美的,包括你的解釋!謝謝!我花了將近一個小時的時間,並且只用了最靈敏的sed結構。 – badlands 2014-12-05 10:44:33