Last active
February 9, 2023 10:46
-
-
Save boppreh/3cf5489da92d85f11e152739320d147e to your computer and use it in GitHub Desktop.
Python implementation of `grep 'lasagna' beef.txt | sort -n`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python implementation of | |
# $ grep 'lasagna' beef.txt | sort -n | uniq | |
import re | |
lines = list(set(line for line in open('beef.txt') if 'lasagna' in line)) | |
lines.sort(key=lambda line: int(re.match('\d*', line)[0] or 0)) | |
for line in lines: print(line, end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment