#!/usr/bin/env python3 with open('/etc/exports') as f: lines = f.readlines() for line in lines: if not line: continue if line[0] == '#': continue start = line.find('(') end = line.find(')') if start == -1 or end == -1: continue parameters = line[start + 1:end].split(',') print(parameters)