- Line with at least two dots print n Next.
- What remains are line with exactly one or none dots. Of these, delete the dot carrying.
sed -e '/\..*\./b' -e '/\./d' file
- remove everything except dots and record the length of this resulting string and compare against one.
awk 'length(gensub(/[^.]/,"","g",t=$0))-1' file
- store line in hold space for later use.
- Try removing a dot.
- if you failed, print line and next read.
- In case no dot remained => exactly one dot in original. So delete it.
- Else, retrieve the original line as it had > 1 dots.
sed -e 'h;s/\.//;T;//!d;g' file
- When the number of dot transliterations is one then assign the list separator($,) whose default value is empty string.
- the -p option will autoprint the current record.
perl -pe 'y|.||-1||($_=$,)' file
- list comprehension along with an if clause to select those lines that split into two or more or none fields.
with open('file') as f:
print(*[l for l in f if len(l.split('.')) != 2],sep='',end='')
Standard grep in which multiple -e statements signify ORing
$ grep -e '\..*\.' -e '^[^.]*$' file