![スペースと数字の削除[閉じる]](https://linux33.com/image/108195/%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%81%A8%E6%95%B0%E5%AD%97%E3%81%AE%E5%89%8A%E9%99%A4%5B%E9%96%89%E3%81%98%E3%82%8B%5D.png)
ただこれを削除したい
0.10
0.10
0.10
0.10
1.4
1.4
1.4
2.7
ただし、行と数字を削除しないでください
activemq 5.6.0+dfsg1-4+deb8u2
akonadi-backend-mysql 1.13.0-2+deb8u2
akonadi-backend-postgresql 1.13.0-2+deb8u2
akonadi-backend-sqlite 1.13.0-2+deb8u2
akonadi-server 1.13.0-2+deb8u2
apache2 2.4.10-10+deb8u5
apache2.2-bin 2.4.10-10+deb8u5
apache2.2-common 2.4.10-10+deb8u5
apache2-bin 2.4.10-10+deb8u5
apache2-data 2.4.10-10+deb8u5
apache2-dev 2.4.10-10+deb8u5
apache2-doc 2.4.10-10+deb8u5
apache2-mpm-event 2.4.10-10+deb8u5
apache2-mpm-itk 2.4.10-10+deb8u5
apache2-mpm-prefork 2.4.10-10+de
答え1
grep -e '^$' -e '^[.]$' -e '[.].*[.]' -e '[^0-9.]' yourfile
ここでは、保持したい行の属性を段階的にフィルタリングします。
a) thoroughly empty lines,
b) lines that are exactly a dot,
c) lines that comprise at least 2 dots,
d) finally, lines that have at least 1 nondigit &/or 1 dot. (Note: a solitary dot
has already been filtered out by step-b) earlier.)
答え2
数字で始まる行をすべて削除するには、以下を試してください。
grep -v "^[0-9]" filename