Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
入門Cureutils
Search
greymd
June 18, 2016
Programming
3
2.5k
入門Cureutils
2016/06/18に開催された「jus共催、第5回初心者向けとは言うものの午前のシェル勉強会/第23回梅雨でモワッとしたシェル芸勉強会」で発表したLT資料です。
greymd
June 18, 2016
Tweet
Share
More Decks by greymd
See All by greymd
Breaking Through Firewalls with Shell-gei
greymd
0
25
狂気!AWS CloudShell細胞分裂!
greymd
0
2.3k
シェル芸人に必要なのは「マスキングテープ」だったのでは
greymd
19
11k
毎日叩ける シェル芸を覚えよう!
greymd
4
4.3k
Other Decks in Programming
See All in Programming
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
6
1.4k
週次リリースを実現するための グローバルアプリ開発
tera_ny
1
1.2k
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
390
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
240
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
1
450
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
940
Alba: Why, How and What's So Interesting
okuramasafumi
0
210
Fibonacci Function Gallery - Part 2
philipschwarz
PRO
0
210
2025.01.17_Sansan × DMM.swift
riofujimon
2
560
Amazon Nova Reelの可能性
hideg
0
200
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
1.3k
QA環境で誰でも自由自在に現在時刻を操って検証できるようにした話
kalibora
1
140
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
67
4.5k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The World Runs on Bad Software
bkeepers
PRO
66
11k
GraphQLとの向き合い方2022年版
quramy
44
13k
Code Reviewing Like a Champion
maltzj
521
39k
Code Review Best Practice
trishagee
65
17k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Transcript
ೖCureutils @grethlen
~$ whoami Yasuhiro Yamada (HN: ͙Ε͞Μ) Twitter: @grethlen ϋΠύʔγΣϧܳΩϡΞΤϯδχΞ ओͳલՊ
• γΣϧܳ x WebεΫϨΠϐϯά (120stock) http://qiita.com/greymd/items/368faf898c161165fee7 • γΣϧܳ x ଟݴޠϚογϡΞοϓ (ͯͿҰҐʣ http://qiita.com/greymd/items/a4ecf8e70f11eb1e5f7 • γΣϧܳ x IoT (͋Γ͕ͪͳIoTܥهࣄ) http://www.slideshare.net/YasuhiroYamada1/arduino-52210988 • γΣϧܳ x Egison (270stock) https://github.com/greymd/egzact ྉཧͰ͖·ͤΜ
ϓϩάϥϛϯάڭҭ *1 https://twitter.com/13Mzawa2/status/741902695712182272/photo/1 2020ΑΓখֶߍ͔Βϓϩάϥϛϯά͕ඞमԽݟࠐΈ γΣϧεΫϦϓτ͔Δখֶੜ *1
ݒ೦.1 ಓ۩ద͔ʁ • ΞϧΰϦζϜ͚ͩڭ͑ͯҝʹͳΔͷ͔ʁ • γΣϧܳͷڭҭ༻πʔϧͱͯ͠ͷ ແବʹߴ͍ϙςϯγϟϧ 1. σʔλߏͷେֶ͞Δɻ ΞϧΰϦζϜ͚ͩͰͳ͍ɻ
2. ײ͞ɻωετ͠ʹ͍͘ɺ ੵΈΛੵΈ্͛Δײ֮ɻ 3. ෦Խͷେ͞ɻ Ұͭͷ෦Ұͭͷ͜ͱΛ͏·͘ɻ → S◦ratchΦϫίϯɻ࣌γΣϧܳ!? vs γΣϧܳͷྫ ڭҭ༻ιϑτͷྫ
ݒ೦.2 ۤखҙࣝͷέΞ ଟ͘ͷڞײʢˢ200RTʣΛੜΜͩ ࠃຽͷΛหͨ͠πΠʔτ*1 *1 https://twitter.com/grethlen/status/722066098758111232
ʲิࢿྉʳϓϦΩϡΞ • ຊ͕ੈքʹތΔ ࠃຽతΞχϝͷҰͭ • 13ઈࢍ์өதʂ ʮຐ๏͔͍ͭϓϦΩϡΞʯ • ςϨϏேܥྻ ༵ே8:30ʙ
γΣϧܳษڧձͷ࣍ͷ ૣ͘ى͖ͯ؍Α͏ *1 http://www.toei-anim.co.jp/tv/precure/ ఱୡ *1
ݒ೦3. ڭһΓ͍ͯΔͷ͔ʁ ্͕Δٕज़ऀͷٻਓഒ*1 Լ͕ΔϓϦΩϡΞͷࢹௌ*2 *1 http://doda.jp/guide/kyujin_bairitsu/#03 *2 http://prehyou2015.hatenablog.com/entry/shichourituichiran → ਂࠁԽ͢ΔएऀͷΩϡΞΤϯδχΞΕɻ
ʲ݁ʳࠓͷຊʹඞཁͳࣄ ʮγΣϧܳ & ϓϦΩϡΞʯ ͳ ٕज़ऀΛ૿͢ɻ
~$ man Cureutils Cureutils ʲ͖Ύ͋ΏʔͪΔͣʳ • ࣍ੈߴΩϡΞITਓࡐཆ༻ίϚϯυूɻ • UNIXॳֶऀͷֶश༻ʹɻ •
ͪΖΜۀʹཱͭɻ • Github: https://github.com/greymd/cureutils • RubyίϚϯυ • rubicure*1ΛґଘϥΠϒϥϦͱͯ͠࠾༻ɻ *1 https://github.com/sue445/rubicure
ಋೖํ๏ RubygemsొࡁΈ *1 • gemͰೖΕΒΕΔɻ $ sudo gem install cureutils
Πϯετʔϧ͢ΔͱcureίϚϯυ͕͑Δɻ • ͍ํͷදࣔɻ $ cure help *1 https://rubygems.org/gems/cureutils
~$ cure precures $ cure precures • ϓϦΩϡΞͷ໊લΛશһग़ྗ *1 *1
ݱࡏ·ͰͷςϨϏγϦʔζͷϝΠϯώϩΠϯͱΩϡΞΤίʔΛؚΊ46ਓɻ ʮΩϡΞʯ͕͔ͭͳ͍ͷؚΉɻΩϡΞ{ϒϥΠτ, ϒϧʔϜ}ͳͲͷ ಉҰਓͰҟ໊ͷϓϦΩϡΞʹͳΔͷഉআɻ೦ͳ͕Βຬͱ܆ؚ·ͣɻ
~$ cure girls $ cure girls • มલͷঁͷࢠͷ໊લΛશһग़ྗ
~$ cure {precures,girls} # ׆༻໘ • ςετ༻μϛʔσʔλ࡞ʹɻ • ৬/ֶߍͰͷ࡞Γʹɻ ʮणݶແݴ͑ΔΜͩɺ͍͢͝Ͷɻ͡Ό͋ϓϦΩϡΞʁʯ
• ࠾༻໘ରࡦʹɻ ʮFizzBuzzͩͤΔΑͶʁ͡Ό͋ϓϦΩϡΞͩͤΔʁʯ ʮ$ cure precuresʯ ʮ͛͐ͬɺγΣϧܳਓʂʯ
$ cure grep (1) $ cat text | cure grep
ࢲΩϡΞϒϥοΫͰ͢ɻ • ϓϦΩϡΞͷ໊લͷΈΛநग़͢Δɻ $ curl -Lso- goo.gl/L3Fp6h | cure grep | head -n 1 ΩϡΞϒϥοΫౖܹͨ͠ɻඞͣɺ… • ύΠϓͰͭͳ͙ͱண৭Λͣ͢ɻ
$ cure grep (2) • ਖ਼نදݱͰPBE͕ར༻Մೳʂ $ cat txt |
cure grep ‘ࢲ[:precure_name:]Ͱ͢ɻ’ ͜Μʹͪɺ ࢲΩϡΞϨϞωʔυͰ͢ɻ • ௨ৗͷBE (Bracket Expression) [:alnum:], [:lower:], [:upper:], [:space:] … • PBE (Precure Bracket Expressin) [:precure_name:] — ϓϦΩϡΞ໊ʹϚον [:human_name:] — ঁͷࢠ໊ʹϚον [:cast_name:] — ༏໊ʹϚον ͳͲ
~$ cure grep (3) γΣϧܳਓ͓ೃછΈͷίϚϯυϥΠϯΦϓγϣϯʂ • -o : Ϛον෦ͷΈग़ྗɻ •
-E : ͨͩͷ֦ுਖ਼نදݱΛ͏ɻ PBEແޮԽɻීஈͷgrepίϚϯυʹมʂ $ cat access.log | cure grep -E '192.168.1.1'
~$ cure grep #׆༻໘ • จষ͔ΒεϜʔζʹϓϦΩϡΞΛநग़ɻ • ࣄͷใࠂॻɺֶߍͷϨϙʔτͳͲɻ • Rubyͷਖ਼نදݱ͕͑Δgrepͱׂͯ͠ͱศར
• ෦ࣜݺͼग़͠*1ͱ͔͑Δ $ echo "aaaa\naabb" | \ cure grep '^(?<name>aa)\g<name>$' aaaa *1 http://docs.ruby-lang.org/ja/1.9.3/doc/spec=2fregexp.html
~$ cure transform • ϓϦΩϡΞΛมͤ͞Δɻ $ echo ‘ࢲͷ໊લेϦίͰ͢ɻ’ | cure
transform ࢲͷ໊લΩϡΞϚδΧϧͰ͢ɻ
~$ cure humanize • ϓϦΩϡΞͷมΛղআ͢Δɻ $ echo ΩϡΞ{ϋʔτ,Τʔε} | cure
humanize ૬ాϚφ ԁѥٱཬ
~$ cure {humanize,transform} # ׆༻໘ • ใͷਖ਼نԽɻ • Ұ୴શͯͷϓϦΩϡΞΛมͤ͞Δɻ •
grepΛ͔͚͘͢͢Δɻ
~$ cure date (1) $ cure date 2016-06-17 21:28:42 ຐ๏͔͍ͭϓϦΩϡΞʂ์өظؒ
• ݱࡏͷ࣌Λදࣔ͢Δɻ • ͦͷ࣌ͷϓϦΩϡΞؔ࿈ͷΠϕϯτදࣔɻ • ࣌์өதͷϓϦΩϡΞɻ • ॳճɾ࠷ऴճ์ө • ϓϦΩϡΞͷੜ • өըͷެ։ ͳͲ
~$ cure date (2) • -d ΦϓγϣϯରԠ $ cure date
-d ‘1 years ago’ • “+”ʹଓ͍ͯͷग़ྗϑΥʔϚοτΛࢦఆՄೳɻ $ cure date ‘+%Y-%m-%d @p’ • %Y : ྐྵ • %m : ݄ 01 - 12 • %d : 01 - 31 • @P : ϓϦΩϡΞؔ࿈ͷΠϕϯτ • ଞͷه๏ରԠ
~$ cure date #׆༻໘ • dateಉ༷ɺϩάͷग़ྗ࣌ࠁͱͯ͠ɻ • ϥΠϑϩάͷΤοηϯεͱͯ͠ɻ • ௨ৗͷdateίϚϯυͱҧ͍
YYYY-mm-dd HH:MM:SS ϑΥʔϚοτͰσϑΥϧτͰग़ྗɻ ͪΐͬͱ͋Γ͕͍ͨɻ
~$ cure echo (1) • ΩϡΞΤίʔͷมޱ্Λग़ྗ͢Δɻ • Φϓγϣϯ • -a
: ߈ܸͷޱ্ΛՃ • -q : ޱ্Λ͙͢ʹදࣔͤ͞Δɻ $ cure echo ΈΜͳͷࢥ͍ΛकΔͨΊʹ # ҎԼུ *1 http://cocoa08.com/anime/4287/ ܶ൛ݶఆͷϓϦΩϡΞ *1
~$ cure echo (2) • ͪΖΜଞͷϓϦΩϡΞʹରԠ • -p ϓϦΩϡΞΛࢦఆͰ͖Δɻ $
cure echo -p sword ϓϦΩϡΞϥϒϦϯΫʂ # ҎԼུ
~$ cure echo #׆༻໘ • ςετ༻μϛʔจষͷੜʹɻ • ҰൠϢʔβ͕rootʹͳΔ࣌ͷܯࠂͱͯ͠ɻ $ echo
“cure echo” >> /root/.bashrc • େ͖ͳྗʢݖݶʣΛ࣋ͬͨ͜ͱΛ֮ࣗͤ͞Δɻ • దٓམͪண࣌ؒ͘Λઃ͚ΒΕΔɻ → Φϖϛεͷݮ
~$ cure janken $ cure janken • ϐΧϦϯδϟϯέϯ͕Ͱ͖Δ • উഊʹΑΓ
ऴྃεςʔλε͕มԽɻ • উར: 0 • ഊ: 1 • ͍͋͜: 2 ϐΧϦϯ͡ΌΜ͚Μ by ΩϡΞϐʔε
~$ cure janken #׆༻໘ • ࣄதͷଉൈ͖ʹɻ • উෛڧ͍ਓ͚͕࣮ͩߦͰ͖ΔεΫϦϓτ࡞ʹɻ • ެฏͳ࡞ۀ୲ʹɻ
$ cure janken && mysql -u user ʮ࠷ॳʹউͬͨਓ͕drop table͠·͠ΐ͏Αɻʯ
ͦͷଞ GithubͰZsh༻ೖྗิεΫϦϓτΛެ։தʂ • Github: https://github.com/greymd/cureutils/blob/ master/etc/cure-completion.zsh RubyΛֶͿͨΊʹ࡞ͬͨͷɻ • RubylistͷํͷϑΟʔυόοΫͬͯ·͢ʂ