added grep

This commit is contained in:
ronny abraham 2025-02-16 17:10:19 +02:00
parent 437abf5af9
commit 8cb56d003f

View file

@ -29,9 +29,9 @@
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1173s][19:33 - curly braces]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1173s][19:33 - curly braces]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1359s][22:39 - python script]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1359s][22:39 - python script]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1707s][28:27 - man command]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1707s][28:27 - man command]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2175s][31:26 - finding files]] *current* + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2175s][31:26 - finding files]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2190s][36:30 - grep]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2190s][36:30 - grep]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2573s][42:53 - fuzzy finder]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2573s][42:53 - fuzzy finder]] *current*
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2649s][44:09 - history substring search]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2649s][44:09 - history substring search]]
* Notes * Notes
@ -286,3 +286,76 @@ shellcheck some_bash_script.sh
- 'tldr' is easier to read - 'tldr' is easier to read
** find ** find
*** grep
- grep TEXT-TO-FIND LOCATION
- this will recursively go through all files in a directory looking for "TEXT"
#+begin_src bash
grep -R TEXT .
#+end_src
*** ripgrep
**** Key Features of rg (ripgrep):
- Faster than grep (built with Rust and optimized for performance).
- Ignores files listed in .gitignore by default.
- Supports recursive searches automatically.
- Better default output formatting.
- Supports regex matching like grep -E.
- Multithreaded searching for better performance on modern CPUs.
**** basic command structure
- search recursively through all files for text
#+begin_src bash
rg "text"
#+end_src
- case insensitive search
#+begin_src bash
rg -i "text"
#+end_src
- show line numbers
#+begin_src bash
rg -n "text"
#+end_src
- search files of the pattern shown
#+begin_src bash
rg "text" --glob "*.txt"
#+end_src
- search through files that are classified under the type given
- pattern example
#+begin_src bash
rg "text" -t txt
#+end_src
- for example type 'txt' would search for
- txt
- md
- rst
- if you want to see the type list use
#+begin_src bash
rg --type-list
#+end_src
- ask for a specified number of lines of context around search match
#+begin_src bash
rg "text" -C 3
#+end_src
- dont ignore hidden files
#+begin_src bash
rg "text" -u
#+end_src
- add stats to search
#+begin_src bash
rg "text" --stats
#+end_src
*** other alternatives
- ack
- ag
** fuzzy finder