3 ms·
A sibling comment already mentions PAWK. You can do cat makefile | pyawk 'if re.match(r"[A-Za-z]", line): print(lineno, fields[1])' in a Python one-liner wi
by networked 3y ago
A sibling comment already mentions PAWK. You can do
cat makefile | pyawk 'if re.match(r"[A-Za-z]", line): print(lineno, fields[1])'
in a Python one-liner without PAWK by abusing list comprehensions:
python -c 'import fileinput, re; [print(re.split(r"\s+", line)[0], fileinput.lineno()) for line in fileinput.input() if re.match(r"[A-Za-z]", line)]' makefile
Edit: Removed a list of other awk replacements to post in a separate comment (https://news.ycombinator.com/item?id=37465164 https://news.ycombinator.com/item?id=37465164).