關於我

我的相片

在此提供一些有關你的資訊,以便其他人確認你是他們要找的Fai。

2008/05/13

sed tips - compressing space

Assume in.txt contains an output of dpkg -l, for example:
ii zip 2.32-1 Archiver for .zip files
To compress the line to single space character in between the columns, we can use this sed pattern for replacing extra spaces to one space:
cat in.txt | sed -e "s/[ ][ ][ ]*/ /g"
This will replace the consecutive spaces to one space.