ã¤ãããã®é«éæ¤ç´¢ç³»ãã¼ã«ã¨ãã£ããagã£ããï¼ã¿ãããªæ°æã¡ã§ãããæè¿ã¯ptã¨ããã®ããããããã§ããï¼æµè¡ã«ã¤ãã¦ãããªãã®ã§ããããããã§ãï¼ ä»ã«ããã®æã®ãã¼ã«ã¨ãã¦ripgrepãªã©ãããã¾ãï¼æµè¡ãå»ãã®æ¿ãããã¼ã«ã®ã¸ã£ã³ã«ã£ã¦ããã¾ãããï¼ã¿ã¹ã¯ã©ã³ãã¼ã¨ãï¼
tl;dr
- æ··å¨ããã¨ã³ã³ã¼ãã£ã³ã°ã横æãã¦æ¤ç´¢ãããï¼âripgrepã使ãã
- å§ç¸®ãããã¡ã¤ã«ã®ä¸ãæ¤ç´¢ãããï¼âagã使ãã
- ããã¯ã¬ãã¡ã¬ã³ã¹ã¨å /å¾èªã¿ã使ãããï¼âagã使ãã
- ç¬èªã®ãã¡ã¤ã«å½¢å¼ãå®ç¾©ãããï¼âripgrepã使ãã
- éãã»ããããï¼âripgrepã使ãã
- ãã¼ã¿ãã«ãªã·ã³ã°ã«ãã¤ããªã欲ããï¼âptã使ãã
agã®å¾©ç¿
ããããagãçã¾ããï¼èæ¯ã¯ã©ããã£ããã®ã ã£ãã®ã§ããããï¼ag以åã«ãã£ãå ¨ææ¤ç´¢ç³»ãã¼ã«ã調ã¹ã¦ã¿ã¾ãï¼
ag(1) – The Silver Searcher. Like ack, but faster.
Recursively search for PATTERN in PATH. Like grep or ack, but faster.
https://github.com/ggreer/the_silver_searcher/blob/master/doc/ag.1.md
agã¯ackãgrepã®ä»£æ¿ã¨ãªããã¨ãdocumentã§å®£è¨ãã¦ãã¾ãï¼éãã®ä»ã«ï¼ackãgrepã¨æ¯ã¹ã¦ã©ã®ãããªã¡ãªãããããã®ã§ãããï¼
It started off as a clone of Ack, but their feature sets have since diverged slightly.
Ackã®ã¯ãã¼ã³ã¨ãã¦å§ã¾ã£ã¦ï¼ãã沢山ã®æ©è½ãç©ã¾ããããã«ãªã£ãããã§ãï¼
https://shoyan.github.io/blog/2015/10/28/highway-faster-than-ag/ ã§ã¯ï¼agãéçºãããèæ¯ã«ã¤ãã¦è§¦ãããã¦ãã¾ãï¼è¦ç´ããã¨ï¼
- grepã¯
.gitignore
ãªã©ã解éããªãããï¼ä½¿ãåæãæªãï¼ - ackã¯
.gitignore
ãªã©ã解éãï¼ããã©ã«ãã§ãã£ã¬ã¯ããªãå帰çã«æ¤ç´¢ã§ãï¼ãã¡ã¤ã«ã¿ã¤ããæå®å¯è½ã§ï¼æ¤ç´¢çµæããã¡ã¤ã«åä½ã§ã¾ã¨ãã¦è¡¨ç¤ºã§ããï¼ - ackã¯perl製ã§é度ã«éçãããï¼
- agã¯é«éãªackãç®æãã¦éçºãããï¼
agã¯Cã§æ¸ããã¦ããã®ã§ï¼é度ã®é¢ã§ã¯å§åçã«åªä½ã§ããï¼ ãã¦ï¼agã«ãæ¬ ç¹ãããï¼EUC-JPãSJIS対å¿ãä¸ååã§ãã£ããï¼æ¤ç´¢çµæã®åºåé åºãå¤ãã£ãããã¾ãï¼
grep | ack | ag | |
---|---|---|---|
é度 | åºæº | æ¯è¼çé ãï¼ | æ¯è¼çéã |
è¨èª | C | perl | C |
ãã£ã¬ã¯ããªãå帰çã«æ¤ç´¢ | -r ãªãã·ã§ã³ãå¿
è¦ |
ããã©ã«ãã§ãã | ããã©ã«ãã§ãã |
ãã¡ã¤ã«ç¨®é¡ãæå® | ã§ããªã | ã§ãã | ã§ãã |
ãã¡ã¤ã«ç¨®é¡ãé¤å¤ | ã§ããªã | ã§ãã | ã§ãã(ååãã¼ã¹) |
ç¬èªã®ãã¡ã¤ã«ç¨®é¡ãå®ç¾© | N/A | ã§ãã | ã§ããªã |
UTF-8/EUC-JP/SJISãæ··å¨ããæ¤ç´¢ | ã§ããªã(1ã¤ã®ã¨ã³ã³ã¼ãã£ã³ã°ã®ã¿) | ã§ããªã(1ã¤ã®ã¨ã³ã³ã¼ãã£ã³ã°ã®ã¿) | ã§ããªã(1ã¤ã®ã¨ã³ã³ã¼ãã£ã³ã°ã®ã¿) |
å§ç¸®ãã¡ã¤ã«å ã®æ¤ç´¢ | ã§ããªã | ã§ããªã | gz/xzã§å¯ |
ripgrep
ãã¹ãagã¨ãã¦æåãªã®ã¯ripgrepã§ããããï¼ripgrepã¯ä»¥ä¸ã®ç¹é·ãã¢ãã¼ã«ãã¦ãã¾ãï¼
ag
ãããå®æ度ã®é«ãï¼.gitignore
ã®å®å ¨ãµãã¼ãï¼- ã«ã¹ã¿ã ãã¡ã¤ã«ã¿ã¤ãã®å®ç¾©ã«ããçµãè¾¼ã¿ã¨é¤å¤ï¼
- UTF-8ã§ãªãã¨ã³ã³ã¼ãã£ã³ã°ã®ãµãã¼ãï¼
ãã ãï¼ripgrepã«ã¯ä»¥ä¸ã®ãããªæ¬ ç¹ãããã¾ãï¼
- æéãªã¼ãããã³æ£è¦è¡¨ç¾ã¨ã³ã¸ã³ã使ã£ã¦ããããï¼ããã¯ã¬ãã¡ã¬ã³ã¹ãå /å¾èªã¿ã使ããªãï¼
- ä»ã®ã¨ããï¼å§ç¸®ãã¡ã¤ã«å ãæ¤ç´¢ã§ããªãï¼
- è¤æ°è¡æ¤ç´¢ããµãã¼ãããäºå®ã¯ãªãï¼
ã¡ãªã¿ã«ripgrep
ã¯rust製ã§ãï¼åãã¦rustãããã¯ããè¦ã¾ããï¼
pt
ä¸çªæ°ã«ãªã£ã¦ããpt
ã«ã¤ãã¦ã¯ã©ãã§ãããï¼ag
ã«å¯¾æããæãã®ãã¼ãã³ã°ã«å¥½æ度ãä¸ããã¾ãï¼
ptã¯ä»¥ä¸ã®ç¹é·ãã¢ãã¼ã«ãã¦ãã¾ãï¼
- UTF-8ï¼EUC-JPï¼Shift_JISãæ¤ç´¢ã§ããï¼
- ãã«ããã©ãããã©ã¼ã ã§åããã¤ããªãæä¾ã§ããï¼
ã¡ãªã¿ã«pt
ã¯go製ã§ãï¼goãªã®ã§ã·ã³ã°ã«ãã¤ããªãçæã§ãã¾ããï¼
ripgrepã主張ããç¹é·ãã«ãã¼ã§ãã¦ããã確èªãã¦ã¿ã¾ãï¼
.gitignore
ã«å¯¾å¿ãã¦ãã(“å®å ¨"ãµãã¼ããã©ããã¯ä¸æ)ï¼- ã«ã¹ã¿ã ãã¡ã¤ã«ã¿ã¤ããå®ç¾©ã§ããªããï¼
- UTF-8以å¤ã®ã¨ã³ã³ã¼ãã£ã³ã°ããµãã¼ããã¦ããï¼
ripgrepã®æ¬ ç¹ãã«ãã¼ãããã©ããã«ã¤ãã¦ã¯ã©ãã§ãããï¼åããã¦ç¢ºèªãã¾ããï¼
- ããã¯ãªãã¡ã¬ã³ã¹ï¼å /å¾èªã¿ã¯åä½ããªãï¼(goã®æ£è¦è¡¨ç¾ã¨ã³ã¸ã³ããããæéãªã¼ãããã³ã§ãããï¼)
- å§ç¸®ãã¡ã¤ã«å ãæ¤ç´¢ã§ããªãï¼
- è¤æ°è¡æ¤ç´¢ãã§ããªãï¼
ã¾ã¨ã
ããã¤ã欲ããæ©è½ããããã¦æ¯è¼ãã¾ããï¼
grep | ack | ag | ripgrep(rg) | pt | |
---|---|---|---|---|---|
é度 | åºæº | æ¯è¼çé ãï¼ | æ¯è¼çéã | éã | ag並㿠|
è¨èª | C | perl | C | Rust | Go |
ãã£ã¬ã¯ããªãå帰çã«æ¤ç´¢ | -r ãªãã·ã§ã³ãå¿
è¦ |
ããã©ã«ãã§ãã | ããã©ã«ãã§ãã | ããã©ã«ãã§ãã | ããã©ã«ãã§ãã |
ãã¡ã¤ã«ç¨®é¡ãæå® | ã§ããªã | ã§ãã(shebangãèªãã) | ã§ãã | ã§ãã | ã§ãã |
ãã¡ã¤ã«ç¨®é¡ãé¤å¤ | ã§ããªã | ã§ãã | ã§ãã | ã§ãã | ã§ãã |
ç¬èªã®ãã¡ã¤ã«ç¨®é¡ãå®ç¾© | N/A | ã§ãã | ã§ããªã | ã§ãã | ã§ããªã |
UTF-8/EUC-JP/SJISãæ··å¨ããæ¤ç´¢ | ã§ããªã(1ã¤ã®ã¨ã³ã³ã¼ãã£ã³ã°ã®ã¿) | ã§ããªã(1ã¤ã®ã¨ã³ã³ã¼ãã£ã³ã°ã®ã¿) | ã§ããªã(1ã¤ã®ã¨ã³ã³ã¼ãã£ã³ã°ã®ã¿) | ã§ãã | ã§ãã |
å§ç¸®ãã¡ã¤ã«å ã®æ¤ç´¢ | ã§ããªã | ã§ããªã | gz/xzã§å¯ | ã§ããªã | ã§ããªã |
åºåæ¡æ°ã®å¶é | ã§ããªã | ã§ããªã | -W /--width ãªãã·ã§ã³ |
-M /max-columns ãªãã·ã§ã³ |
ã§ããªã |
ããã¯ãªãã¡ã¬ã³ã¹ | ã§ãã | ã§ãã | ã§ãã | ã§ããªã | ã§ããªã |
å /å¾èªã¿ | -P ãªãã·ã§ã³ã§å¯ |
ã§ãã | ã§ãã | ã§ããªã | ã§ããªã |
ãããããåå¾è¡ã®è¡¨ç¤º | -A /-B /-C ãªãã·ã§ã³ã§å¯ |
grepã¨åæ§ | grepã¨åæ§ | grepã¨åæ§ | grepã¨åæ§ |
é åºã | å¤ãããªã | å¤ãããªã | å¤ãã | å¤ãã(-j1 ã§ã·ã³ã°ã«ã¹ã¬ããã«ããã°å¯) |
å¤ãã |