Upgrade to Pro — share decks privately, control downloads, hide ads and more …

入門Cureutils

greymd
June 18, 2016

 入門Cureutils

2016/06/18に開催された「jus共催、第5回初心者向けとは言うものの午前のシェル勉強会/第23回梅雨でモワッとしたシェル芸勉強会」で発表したLT資料です。

greymd

June 18, 2016
Tweet

More Decks by greymd

Other Decks in Programming

Transcript

  1. ~$ 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 ྉཧͰ͖·ͤΜ
  2. ݒ೦.1 ಓ۩͸ద੾͔ʁ • ΞϧΰϦζϜ͚ͩڭ͑ͯҝʹͳΔͷ͔ʁ • γΣϧܳͷڭҭ༻πʔϧͱͯ͠ͷ
 ແବʹߴ͍ϙςϯγϟϧ 1. σʔλߏ଄ͷେ੾͞΋ֶ΂Δɻ
 ΞϧΰϦζϜ͚ͩͰ͸ͳ͍ɻ

    2. ௚ײ͞ɻωετ͠ʹ͍͘ɺ
 ੵΈ໦ΛੵΈ্͛Δײ֮ɻ 3. ෦඼Խͷେ੾͞ɻ
 Ұͭͷ෦඼͸Ұͭͷ͜ͱΛ͏·͘ɻ → S◦ratch͸Φϫίϯɻ࣌୅͸γΣϧܳ!? vs γΣϧܳͷྫ ڭҭ༻ιϑτͷྫ
  3. ~$ man Cureutils Cureutils ʲ͖Ύ͋ΏʔͪΔͣʳ • ࣍ੈ୅ߴ౓ΩϡΞITਓࡐཆ੒༻ίϚϯυूɻ • UNIXॳֶऀͷֶश༻ʹɻ •

    ΋ͪΖΜۀ຿ʹ΋໾ཱͭɻ • Github: https://github.com/greymd/cureutils • Ruby੡ίϚϯυ • rubicure*1ΛґଘϥΠϒϥϦͱͯ͠࠾༻ɻ *1 https://github.com/sue445/rubicure
  4. ಋೖํ๏ Rubygemsొ࿥ࡁΈ *1 • gemͰೖΕΒΕΔɻ $ sudo gem install cureutils

    Πϯετʔϧ͢ΔͱcureίϚϯυ͕࢖͑Δɻ • ࢖͍ํͷදࣔɻ $ cure help *1 https://rubygems.org/gems/cureutils
  5. ~$ cure precures $ cure precures • ϓϦΩϡΞͷ໊લΛશһग़ྗ *1 *1

    ݱࡏ·ͰͷςϨϏγϦʔζͷϝΠϯώϩΠϯͱΩϡΞΤίʔΛؚΊ46ਓɻ
 ʮΩϡΞʯ͕͔ͭͳ͍΋ͷ΋ؚΉɻΩϡΞ{ϒϥΠτ, ϒϧʔϜ}ͳͲͷ
 ಉҰਓ෺Ͱҟ໊ͷϓϦΩϡΞʹͳΔ΋ͷ͸ഉআɻ࢒೦ͳ͕Βຬͱ܆͸ؚ·ͣɻ
  6. ~$ cure {precures,girls}
 # ׆༻৔໘ • ςετ༻μϛʔσʔλ࡞੒ʹɻ • ৬৔/ֶߍͰͷ࿩୊࡞Γʹɻ
 ʮणݶແݴ͑ΔΜͩɺ͍͢͝Ͷɻ͡Ό͋ϓϦΩϡΞ͸ʁʯ

    • ࠾༻໘઀ରࡦʹɻ
 ʮFizzBuzzͩͤΔΑͶʁ͡Ό͋ϓϦΩϡΞͩͤΔʁʯ
 ʮ$ cure precuresʯ
 ʮ͛͐ͬɺγΣϧܳਓʂʯ
  7. $ cure grep (1) $ cat text | cure grep

    ࢲ͸ΩϡΞϒϥοΫͰ͢ɻ • ϓϦΩϡΞͷ໊લͷΈΛநग़͢Δɻ $ curl -Lso- goo.gl/L3Fp6h | cure grep | head -n 1
 ΩϡΞϒϥοΫ͸ౖܹͨ͠ɻඞͣɺ… • ύΠϓͰͭͳ͙ͱண৭Λ͸ͣ͢ɻ
  8. $ 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:] — ੠༏໊ʹϚον
 ͳͲ
  9. ~$ cure grep (3) γΣϧܳਓ͓ೃછΈͷίϚϯυϥΠϯΦϓγϣϯ΋ʂ • -o : Ϛον෦෼ͷΈग़ྗɻ •

    -E : ͨͩͷ֦ுਖ਼نදݱΛ࢖͏ɻ
 PBEແޮԽɻීஈͷgrepίϚϯυʹม਎ʂ $ cat access.log | cure grep -E '192.168.1.1'
  10. ~$ 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
  11. ~$ cure date (1) $ cure date 2016-06-17 21:28:42 ຐ๏͔͍ͭϓϦΩϡΞʂ์өظؒ

    • ݱࡏͷ೔࣌Λදࣔ͢Δɻ • ͦͷ࣌ͷϓϦΩϡΞؔ࿈ͷΠϕϯτ΋දࣔɻ • ౰࣌์өதͷϓϦΩϡΞɻ • ॳճɾ࠷ऴճ์ө೔ • ϓϦΩϡΞͷ஀ੜ೔ • өըͷެ։೔ ͳͲ
  12. ~$ cure date (2) • -d ΦϓγϣϯରԠ $ cure date

    -d ‘1 years ago’ • “+”ʹଓ͍ͯ೔෇ͷग़ྗϑΥʔϚοτΛࢦఆՄೳɻ $ cure date ‘+%Y-%m-%d @p’ • %Y : ੢ྐྵ • %m : ݄ 01 - 12 • %d : ೔ 01 - 31 • @P : ϓϦΩϡΞؔ࿈ͷΠϕϯτ • ଞͷه๏΋ରԠ
  13. ~$ cure echo (1) • ΩϡΞΤίʔͷม਎ޱ্Λग़ྗ͢Δɻ • Φϓγϣϯ • -a

    : ߈ܸͷޱ্Λ௥Ճ • -q : ޱ্Λ͙͢ʹදࣔͤ͞Δɻ $ cure echo ΈΜͳͷࢥ͍ΛकΔͨΊʹ # ҎԼུ *1 http://cocoa08.com/anime/4287/ ܶ৔൛ݶఆͷϓϦΩϡΞ *1
  14. ~$ cure echo #׆༻৔໘ • ςετ༻μϛʔจষͷੜ੒ʹɻ • ҰൠϢʔβ͕rootʹͳΔ࣌ͷܯࠂͱͯ͠ɻ $ echo

    “cure echo” >> /root/.bashrc • େ͖ͳྗʢݖݶʣΛ࣋ͬͨ͜ͱΛ֮ࣗͤ͞Δɻ • దٓམͪண࣌ؒ͘Λઃ͚ΒΕΔɻ
 → Φϖϛεͷ௿ݮ
  15. ~$ cure janken $ cure janken • ϐΧϦϯδϟϯέϯ͕Ͱ͖Δ • উഊʹΑΓ


    ऴྃεςʔλε͕มԽɻ • উར: 0 • ഊ๺: 1 • ͍͋͜: 2 ϐΧϦϯ͡ΌΜ͚Μ by ΩϡΞϐʔε