Last active
August 29, 2015 14:08
-
-
Save st98/a6428452d6d76369060e to your computer and use it in GitHub Desktop.
雑、grep でいける。
This file contains 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
:: $ m \d+ -s ho12ge34 | |
:: 12 | |
:: 34 | |
:: | |
:: $ echo ho12ge34 | grep -o [0-9]\\+ - | |
:: 12 | |
:: 34 | |
:: | |
@echo off | |
python -c "import re, sys;print('usage: m pattern file\n m pattern -s string' if '-h' in sys.argv or len(sys.argv) <= 2 else '\n'.join(re.findall(sys.argv[1],sys.argv[sys.argv.index('-s') + 1] if '-s' in sys.argv[2:] else open(sys.argv[2], 'r', encoding='utf-8').read())))" %* |
This file contains 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
# coding: utf-8 | |
import re, sys; | |
print( | |
'usage: m pattern file\n m pattern -s string' | |
if '-h' in sys.argv or len(sys.argv) <= 2 | |
else '\n'.join(re.findall( | |
sys.argv[1], | |
sys.argv[sys.argv.index('-s') + 1] | |
if '-s' in sys.argv[2:] | |
else open(sys.argv[2], 'r', encoding='utf-8').read() | |
))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment