如何删除BASH中包含少于两个/的所有行?

Vil*_*age 2 bash grep sed

如何从仅包含一个或不包含的文件中删除所有行/?例如file.txt:

This / line contains/ more than / one of the characters/.
This / line contains just one.
This / line/ also has/too many/.
Run Code Online (Sandbox Code Playgroud)

输出将是:

This / line contains/ more than / one of the characters/.
This / line/ also has/too many/.
Run Code Online (Sandbox Code Playgroud)

我试过grep ^[^/]*/*[^/]$ file.txt,但这似乎打印了一切.

Ken*_*ent 5

试试这个:

awk -F/ 'NF>2' file
Run Code Online (Sandbox Code Playgroud)

测试:

kent$ (master|?) echo "This / line contains/ more than / one of the characters/.
dquote> This / line contains just one.
dquote> This / line/ also has/too many/."|awk -F/ 'NF>2'
This / line contains/ more than / one of the characters/.
This / line/ also has/too many/.
Run Code Online (Sandbox Code Playgroud)