Sample Header Ad - 728x90

How to make this search faster in fgrep/Ag?

6 votes
2 answers
905 views
I am thinking methods to make the search faster and/or better which principally uses fgrep or ag. Code which searches the word and case-insensitively at $HOME, and redirects a list of matches to vim find -L $HOME -xtype f -name "*.tex" \ -exec fgrep -l -i "and" {} + 2>/dev/null | vim -R - It is faster with ag because of parallelism and ack find -L $HOME -xtype f -name "*.tex" \ -exec ag -l -i "and" {} + 2>/dev/null | vim -R - Statistics --- Small group average statistics with fgrep and ag by time fgrep ag terdon1 terdon2 terdon3 muru user 0.41s 0.32s 0.14s 0.22s 0.18s 0.12s sys 0.46s 0.44s 0.26s 0.28s 0.30s 0.32s Cases terdon1 and terdon3 can be equal fast. I get great fluctuations with those two. Some Ranking by sys time (not best criteria!) 1. terdon1 2. terdon2 3. terdon3 4. muru 5. ag 6. fgrep Abbreviations --- - terdon1 = terdon-many-find-grep - terdon2 = terdon-many-find-fgrep - terdon3 = terdon-many-find-ag (without F because not exists in ag) Other codes --- muru's proposal in comments grep -RFli "and" "$HOME" --include="*.tex" | vim -R - OS: Debian 8.5 Hardware: Asus Zenbook UX303UA
Asked by Léo Léopold Hertz 준영 (7138 rep)
Dec 24, 2016, 12:35 PM
Last activity: Dec 25, 2016, 10:05 AM