我試圖在AIX上使用以下命令從文件中刪除回車(\r
),但它也刪除了我的最後一行。有什麼建議麼?Sed腳本命令截斷最後一行
sed -e 's/\r\n/\n/g' ./excprule > ./excprule.tst
命令序列:
dev1:> sed -e 's/\r\n/\n/g' ./test_file > ./test_file.tst dev1:> diff test_file.tst test_file diff: 0653-827 Missing newline at the end of file test_file. 26a27 > Trailer 25
編輯:用perl的做同樣的事情找到一個解決辦法,但想知道爲什麼這是行不通的。
顯然,差異抱怨你的原始文件。 基本上,它說它以\ r結尾,而它應該以\ n結尾。 顯然,你的sed命令沒有錯。 – tonio 2010-03-24 14:06:42