@hybridlabor-api/aos 4.8.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/.agents/agents.md +1 -1
  2. package/.agents/nodes.json +1 -1
  3. package/.agents/vendor-manifest.json +23 -1
  4. package/.claude/agents/godmode-media-eventtech.md +1 -1
  5. package/.claude/hooks/conventional-commits.mjs +125 -0
  6. package/.claude/hooks/env-file-protection.mjs +105 -0
  7. package/.claude/hooks/go-gate.mjs +101 -81
  8. package/.claude/settings.json +13 -0
  9. package/.opencode/agents/godmode-media-eventtech.md +1 -1
  10. package/.opencode/plugins/bdb-aos.js +31 -4
  11. package/README.de.md +1 -1
  12. package/README.md +1 -1
  13. package/README.pt.md +1 -1
  14. package/THIRD_PARTY_NOTICES.md +88 -0
  15. package/docs/skills_table.md +1 -1
  16. package/installer.js +174 -46
  17. package/package.json +6 -2
  18. package/packages/aos-cli/README.md +80 -0
  19. package/packages/aos-cli/bin/aos-cli.mjs +134 -0
  20. package/packages/aos-cli/core-skills.json +12 -0
  21. package/packages/aos-cli/extensions/aos.ts +321 -0
  22. package/packages/aos-cli/package-lock.json +1923 -0
  23. package/packages/aos-cli/package.json +29 -0
  24. package/packages/aos-cli/scripts/check-theme.mjs +63 -0
  25. package/packages/aos-cli/themes/aos.json +97 -0
  26. package/scripts/build-plugin-manifest.mjs +131 -0
  27. package/scripts/validate-skills.mjs +81 -6
  28. package/skills/basic/ao-orchestrator/SKILL.md +116 -0
  29. package/skills/global_config/agenttrail/SKILL.md +6 -1
  30. package/skills/global_config/ask-tim/SKILL.md +4 -4
  31. package/skills/global_config/bash-script-generator/SKILL.md +201 -0
  32. package/skills/global_config/bash-script-generator/assets/templates/standard-template.sh +96 -0
  33. package/skills/global_config/bash-script-generator/docs/bash-scripting-guide.md +729 -0
  34. package/skills/global_config/bash-script-generator/docs/generation-best-practices.md +193 -0
  35. package/skills/global_config/bash-script-generator/docs/script-patterns.md +566 -0
  36. package/skills/global_config/bash-script-generator/docs/text-processing-guide.md +437 -0
  37. package/skills/global_config/bash-script-generator/examples/log-analyzer.sh +92 -0
  38. package/skills/global_config/bash-script-generator/scripts/generate_script_template.sh +123 -0
  39. package/skills/global_config/bash-script-generator/scripts/run_ci_checks.sh +172 -0
  40. package/skills/global_config/bash-script-generator/scripts/test_generator.sh +413 -0
  41. package/skills/global_config/bash-script-validator/SKILL.md +249 -0
  42. package/skills/global_config/bash-script-validator/docs/awk-reference.md +449 -0
  43. package/skills/global_config/bash-script-validator/docs/bash-reference.md +468 -0
  44. package/skills/global_config/bash-script-validator/docs/common-mistakes.md +623 -0
  45. package/skills/global_config/bash-script-validator/docs/grep-reference.md +395 -0
  46. package/skills/global_config/bash-script-validator/docs/regex-reference.md +391 -0
  47. package/skills/global_config/bash-script-validator/docs/sed-reference.md +454 -0
  48. package/skills/global_config/bash-script-validator/docs/shell-reference.md +463 -0
  49. package/skills/global_config/bash-script-validator/docs/shellcheck-reference.md +399 -0
  50. package/skills/global_config/bash-script-validator/examples/bad-bash.sh +55 -0
  51. package/skills/global_config/bash-script-validator/examples/bad-shell.sh +54 -0
  52. package/skills/global_config/bash-script-validator/examples/good-bash.sh +71 -0
  53. package/skills/global_config/bash-script-validator/examples/good-shell.sh +69 -0
  54. package/skills/global_config/bash-script-validator/scripts/run_ci_checks.sh +23 -0
  55. package/skills/global_config/bash-script-validator/scripts/shellcheck_wrapper.sh +174 -0
  56. package/skills/global_config/bash-script-validator/scripts/test_validate.sh +446 -0
  57. package/skills/global_config/bash-script-validator/scripts/validate.sh +512 -0
  58. package/skills/global_config/ci-pipeline/SKILL.md +135 -0
  59. package/skills/global_config/dispatching-parallel-agents/SKILL.md +170 -0
  60. package/skills/global_config/dockerfile-generator/SKILL.md +1038 -0
  61. package/skills/global_config/dockerfile-generator/examples/example.dockerignore +95 -0
  62. package/skills/global_config/dockerfile-generator/examples/golang-distroless.Dockerfile +34 -0
  63. package/skills/global_config/dockerfile-generator/examples/java-springboot.Dockerfile +45 -0
  64. package/skills/global_config/dockerfile-generator/examples/nextjs-production.Dockerfile +49 -0
  65. package/skills/global_config/dockerfile-generator/examples/nodejs-multistage.Dockerfile +55 -0
  66. package/skills/global_config/dockerfile-generator/examples/python-fastapi.Dockerfile +48 -0
  67. package/skills/global_config/dockerfile-generator/references/language_specific_guides.md +510 -0
  68. package/skills/global_config/dockerfile-generator/references/multistage_builds.md +570 -0
  69. package/skills/global_config/dockerfile-generator/references/optimization_patterns.md +492 -0
  70. package/skills/global_config/dockerfile-generator/references/security_best_practices.md +375 -0
  71. package/skills/global_config/dockerfile-generator/scripts/generate_dockerignore.sh +199 -0
  72. package/skills/global_config/dockerfile-generator/scripts/generate_golang.sh +172 -0
  73. package/skills/global_config/dockerfile-generator/scripts/generate_java.sh +185 -0
  74. package/skills/global_config/dockerfile-generator/scripts/generate_nodejs.sh +279 -0
  75. package/skills/global_config/dockerfile-generator/scripts/generate_python.sh +218 -0
  76. package/skills/global_config/dockerfile-generator/scripts/test_generator.sh +210 -0
  77. package/skills/global_config/dockerfile-validator/SKILL.md +300 -0
  78. package/skills/global_config/dockerfile-validator/examples/.dockerignore.example +34 -0
  79. package/skills/global_config/dockerfile-validator/examples/bad-example.Dockerfile +37 -0
  80. package/skills/global_config/dockerfile-validator/examples/golang-distroless.Dockerfile +50 -0
  81. package/skills/global_config/dockerfile-validator/examples/good-example.Dockerfile +52 -0
  82. package/skills/global_config/dockerfile-validator/examples/python-optimized.Dockerfile +53 -0
  83. package/skills/global_config/dockerfile-validator/examples/security-issues.Dockerfile +42 -0
  84. package/skills/global_config/dockerfile-validator/references/docker_best_practices.md +348 -0
  85. package/skills/global_config/dockerfile-validator/references/optimization_guide.md +473 -0
  86. package/skills/global_config/dockerfile-validator/references/security_checklist.md +208 -0
  87. package/skills/global_config/dockerfile-validator/scripts/dockerfile-validate.sh +699 -0
  88. package/skills/global_config/dockerfile-validator/scripts/test_validate.sh +35 -0
  89. package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn-lock-read.Dockerfile +6 -0
  90. package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn.Dockerfile +6 -0
  91. package/skills/global_config/dockerfile-validator/tests/fixtures/from-platform-nonroot.Dockerfile +7 -0
  92. package/skills/global_config/dockerfile-validator/tests/test_regression.sh +164 -0
  93. package/skills/global_config/finishing-a-development-branch/SKILL.md +228 -0
  94. package/skills/global_config/github-actions-generator/SKILL.md +353 -0
  95. package/skills/global_config/github-actions-generator/assets/templates/action/composite/action.yml +82 -0
  96. package/skills/global_config/github-actions-generator/assets/templates/action/docker/Dockerfile +25 -0
  97. package/skills/global_config/github-actions-generator/assets/templates/action/docker/action.yml +42 -0
  98. package/skills/global_config/github-actions-generator/assets/templates/action/docker/entrypoint.sh +27 -0
  99. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/action.yml +33 -0
  100. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/index.js +50 -0
  101. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/package.json +27 -0
  102. package/skills/global_config/github-actions-generator/assets/templates/workflow/basic_workflow.yml +242 -0
  103. package/skills/global_config/github-actions-generator/assets/templates/workflow/reusable_workflow.yml +106 -0
  104. package/skills/global_config/github-actions-generator/examples/README.md +147 -0
  105. package/skills/global_config/github-actions-generator/examples/actions/setup-node-cached/action.yml +93 -0
  106. package/skills/global_config/github-actions-generator/examples/caching/docker-buildkit.yml +256 -0
  107. package/skills/global_config/github-actions-generator/examples/security/dependency-review.yml +62 -0
  108. package/skills/global_config/github-actions-generator/examples/security/sbom-attestation.yml +119 -0
  109. package/skills/global_config/github-actions-generator/examples/triggers/chatops-commands.yml +475 -0
  110. package/skills/global_config/github-actions-generator/examples/triggers/repository-dispatch.yml +418 -0
  111. package/skills/global_config/github-actions-generator/examples/triggers/workflow-orchestration.yml +404 -0
  112. package/skills/global_config/github-actions-generator/examples/workflows/docker-build-push.yml +68 -0
  113. package/skills/global_config/github-actions-generator/examples/workflows/go-ci.yml +161 -0
  114. package/skills/global_config/github-actions-generator/examples/workflows/monorepo-ci.yml +340 -0
  115. package/skills/global_config/github-actions-generator/examples/workflows/multi-environment-deploy.yml +406 -0
  116. package/skills/global_config/github-actions-generator/examples/workflows/nodejs-ci.yml +122 -0
  117. package/skills/global_config/github-actions-generator/examples/workflows/python-ci.yml +157 -0
  118. package/skills/global_config/github-actions-generator/examples/workflows/scheduled-tasks.yml +376 -0
  119. package/skills/global_config/github-actions-generator/references/advanced-triggers.md +917 -0
  120. package/skills/global_config/github-actions-generator/references/best-practices.md +755 -0
  121. package/skills/global_config/github-actions-generator/references/common-actions.md +715 -0
  122. package/skills/global_config/github-actions-generator/references/custom-actions.md +320 -0
  123. package/skills/global_config/github-actions-generator/references/expressions-and-contexts.md +688 -0
  124. package/skills/global_config/github-actions-generator/references/modern-features.md +421 -0
  125. package/skills/global_config/github-actions-generator/scripts/test_generator.sh +344 -0
  126. package/skills/global_config/github-actions-templates/SKILL.md +7 -0
  127. package/skills/global_config/github-actions-validator/SKILL.md +576 -0
  128. package/skills/global_config/github-actions-validator/examples/README.md +88 -0
  129. package/skills/global_config/github-actions-validator/examples/outdated-versions.yml +76 -0
  130. package/skills/global_config/github-actions-validator/examples/valid-ci.yml +79 -0
  131. package/skills/global_config/github-actions-validator/examples/with-errors.yml +47 -0
  132. package/skills/global_config/github-actions-validator/references/act_usage.md +233 -0
  133. package/skills/global_config/github-actions-validator/references/action_versions.md +122 -0
  134. package/skills/global_config/github-actions-validator/references/actionlint_usage.md +343 -0
  135. package/skills/global_config/github-actions-validator/references/common_errors.md +512 -0
  136. package/skills/global_config/github-actions-validator/references/modern_features.md +384 -0
  137. package/skills/global_config/github-actions-validator/references/runners.md +317 -0
  138. package/skills/global_config/github-actions-validator/scripts/install_tools.sh +113 -0
  139. package/skills/global_config/github-actions-validator/scripts/validate_workflow.sh +910 -0
  140. package/skills/global_config/github-actions-validator/tests/test_validate_workflow.sh +237 -0
  141. package/skills/global_config/makefile-generator/SKILL.md +614 -0
  142. package/skills/global_config/makefile-generator/assets/templates/.gitkeep +1 -0
  143. package/skills/global_config/makefile-generator/docs/makefile-structure.md +530 -0
  144. package/skills/global_config/makefile-generator/docs/optimization-guide.md +784 -0
  145. package/skills/global_config/makefile-generator/docs/patterns-guide.md +642 -0
  146. package/skills/global_config/makefile-generator/docs/security-guide.md +361 -0
  147. package/skills/global_config/makefile-generator/docs/targets-guide.md +642 -0
  148. package/skills/global_config/makefile-generator/docs/variables-guide.md +596 -0
  149. package/skills/global_config/makefile-generator/scripts/add_standard_targets.sh +539 -0
  150. package/skills/global_config/makefile-generator/scripts/generate_makefile_template.sh +690 -0
  151. package/skills/global_config/makefile-generator/test/test_helper_scripts.sh +190 -0
  152. package/skills/global_config/makefile-validator/SKILL.md +244 -0
  153. package/skills/global_config/makefile-validator/docs/bake-tool.md +1000 -0
  154. package/skills/global_config/makefile-validator/docs/best-practices.md +858 -0
  155. package/skills/global_config/makefile-validator/docs/common-mistakes.md +944 -0
  156. package/skills/global_config/makefile-validator/examples/bad-makefile.mk +77 -0
  157. package/skills/global_config/makefile-validator/examples/good-makefile.mk +103 -0
  158. package/skills/global_config/makefile-validator/scripts/test_validate.sh +382 -0
  159. package/skills/global_config/makefile-validator/scripts/validate_makefile.sh +712 -0
  160. package/skills/global_config/{MCP_Manage → mcp-manage}/SKILL.md +3 -3
  161. package/skills/global_config/requesting-code-review/SKILL.md +98 -0
  162. package/skills/global_config/requesting-code-review/code-reviewer.md +198 -0
  163. package/skills/global_config/using-git-worktrees/SKILL.md +170 -0
  164. package/skills/global_config/verification-before-completion/SKILL.md +123 -0
  165. package/skills/global_config/writing-plans/SKILL.md +126 -46
  166. package/skills/global_config/writing-plans-legacy/SKILL.md +139 -0
@@ -0,0 +1,395 @@
1
+ # GNU grep Reference Guide
2
+
3
+ ## Overview
4
+
5
+ grep (Global Regular Expression Print) searches for patterns in text files. It's one of the most commonly used Unix tools.
6
+
7
+ **Official Manual:** https://www.gnu.org/software/grep/manual/
8
+ **Man Page:** `man grep`
9
+
10
+ ## Basic Syntax
11
+
12
+ ```bash
13
+ grep [OPTIONS] PATTERN [FILE...]
14
+ grep [OPTIONS] -e PATTERN ... [FILE...]
15
+ grep [OPTIONS] -f PATTERN_FILE ... [FILE...]
16
+ ```
17
+
18
+ ## Common Options
19
+
20
+ ### Basic Options
21
+ ```bash
22
+ -i, --ignore-case # Case-insensitive search
23
+ -v, --invert-match # Invert match (select non-matching lines)
24
+ -w, --word-regexp # Match whole words only
25
+ -x, --line-regexp # Match whole lines only
26
+ -c, --count # Count matching lines
27
+ -n, --line-number # Show line numbers
28
+ -H, --with-filename # Print filename with matches
29
+ -h, --no-filename # Suppress filename output
30
+ -l, --files-with-matches # Print only filenames with matches
31
+ -L, --files-without-match # Print only filenames without matches
32
+ ```
33
+
34
+ ### Context Options
35
+ ```bash
36
+ -A NUM, --after-context=NUM # Print NUM lines after match
37
+ -B NUM, --before-context=NUM # Print NUM lines before match
38
+ -C NUM, --context=NUM # Print NUM lines before and after
39
+ ```
40
+
41
+ ### Regular Expression Options
42
+ ```bash
43
+ -E, --extended-regexp # Use Extended Regular Expressions (ERE)
44
+ -F, --fixed-strings # Treat PATTERN as fixed strings, not regex
45
+ -G, --basic-regexp # Use Basic Regular Expressions (BRE) - default
46
+ -P, --perl-regexp # Use Perl-compatible regex (PCRE)
47
+ ```
48
+
49
+ ### Output Options
50
+ ```bash
51
+ -o, --only-matching # Print only matched parts
52
+ -q, --quiet, --silent # Suppress output, just return exit code
53
+ --color[=WHEN] # Colorize output (auto, always, never)
54
+ -s, --no-messages # Suppress error messages
55
+ ```
56
+
57
+ ### File Selection
58
+ ```bash
59
+ -r, --recursive # Recursive search
60
+ -R, --dereference-recursive # Recursive, following symlinks
61
+ --include=PATTERN # Search only files matching PATTERN
62
+ --exclude=PATTERN # Skip files matching PATTERN
63
+ --exclude-dir=PATTERN # Skip directories matching PATTERN
64
+ ```
65
+
66
+ ## Common Usage Patterns
67
+
68
+ ### Basic Searches
69
+ ```bash
70
+ # Simple string search
71
+ grep "error" logfile.txt
72
+
73
+ # Case-insensitive search
74
+ grep -i "error" logfile.txt
75
+
76
+ # Search for whole word
77
+ grep -w "error" logfile.txt
78
+
79
+ # Count matches
80
+ grep -c "error" logfile.txt
81
+
82
+ # Show line numbers
83
+ grep -n "error" logfile.txt
84
+ ```
85
+
86
+ ### Multiple Files
87
+ ```bash
88
+ # Search in multiple files
89
+ grep "pattern" file1.txt file2.txt
90
+
91
+ # Search in all txt files
92
+ grep "pattern" *.txt
93
+
94
+ # Recursive search
95
+ grep -r "pattern" /path/to/dir
96
+
97
+ # Recursive with file pattern
98
+ grep -r --include="*.log" "error" /var/log
99
+ ```
100
+
101
+ ### Context Display
102
+ ```bash
103
+ # Show 3 lines after match
104
+ grep -A 3 "error" logfile.txt
105
+
106
+ # Show 3 lines before match
107
+ grep -B 3 "error" logfile.txt
108
+
109
+ # Show 3 lines before and after
110
+ grep -C 3 "error" logfile.txt
111
+ ```
112
+
113
+ ### Invert Match
114
+ ```bash
115
+ # Show lines that DON'T contain pattern
116
+ grep -v "debug" logfile.txt
117
+
118
+ # Exclude multiple patterns
119
+ grep -v "debug\|info" logfile.txt
120
+ ```
121
+
122
+ ### Multiple Patterns
123
+ ```bash
124
+ # Match any pattern (OR)
125
+ grep -e "error" -e "warning" file.txt
126
+ grep "error\|warning" file.txt
127
+
128
+ # Match all patterns (AND) - requires pipeline
129
+ grep "error" file.txt | grep "critical"
130
+ ```
131
+
132
+ ### File Selection
133
+ ```bash
134
+ # List files containing match
135
+ grep -l "pattern" *.txt
136
+
137
+ # List files NOT containing match
138
+ grep -L "pattern" *.txt
139
+
140
+ # Recursive with excludes
141
+ grep -r --exclude-dir=".git" "pattern" .
142
+ grep -r --exclude="*.min.js" "pattern" .
143
+ ```
144
+
145
+ ## Regular Expressions in grep
146
+
147
+ ### Basic Regular Expressions (BRE) - Default
148
+
149
+ ```bash
150
+ # BRE Metacharacters (no escaping needed)
151
+ . # Any single character
152
+ ^ # Start of line
153
+ $ # End of line
154
+ [...] # Character class
155
+ [^...] # Negated character class
156
+ * # Zero or more of previous
157
+
158
+ # BRE Metacharacters (MUST be escaped)
159
+ \+ # One or more (requires \)
160
+ \? # Zero or one (requires \)
161
+ \{m,n\} # Between m and n occurrences (requires \)
162
+ \(...\) # Group (requires \)
163
+ \| # Alternation (requires \)
164
+ ```
165
+
166
+ ### BRE Examples
167
+ ```bash
168
+ # Match lines starting with "Error"
169
+ grep "^Error" file.txt
170
+
171
+ # Match lines ending with "failed"
172
+ grep "failed$" file.txt
173
+
174
+ # Match any character
175
+ grep "a.c" file.txt # Matches abc, aXc, a5c
176
+
177
+ # Character class
178
+ grep "[0-9]" file.txt # Match any digit
179
+ grep "[A-Za-z]" file.txt # Match any letter
180
+
181
+ # One or more (escaped)
182
+ grep "a\+b" file.txt # Matches ab, aab, aaab
183
+
184
+ # Groups and alternation (escaped)
185
+ grep "\(error\|warning\)" file.txt
186
+ ```
187
+
188
+ ### Extended Regular Expressions (ERE) - grep -E
189
+
190
+ ```bash
191
+ # ERE - No escaping needed for +, ?, |, (), {}
192
+ + # One or more
193
+ ? # Zero or one
194
+ {m,n} # Between m and n occurrences
195
+ (...) # Group
196
+ | # Alternation
197
+ ```
198
+
199
+ ### ERE Examples
200
+ ```bash
201
+ # One or more (no escape)
202
+ grep -E "a+b" file.txt
203
+
204
+ # Zero or one
205
+ grep -E "colou?r" file.txt # Matches color or colour
206
+
207
+ # Alternation
208
+ grep -E "(error|warning)" file.txt
209
+
210
+ # Quantifiers
211
+ grep -E "[0-9]{3}-[0-9]{4}" file.txt # Phone: 123-4567
212
+ grep -E "[0-9]{1,3}" file.txt # 1 to 3 digits
213
+
214
+ # Groups
215
+ grep -E "(http|https)://[^ ]+" file.txt # URLs
216
+ ```
217
+
218
+ ## Character Classes
219
+
220
+ ### POSIX Character Classes
221
+ ```bash
222
+ [:alnum:] # Alphanumeric [A-Za-z0-9]
223
+ [:alpha:] # Alphabetic [A-Za-z]
224
+ [:digit:] # Digits [0-9]
225
+ [:lower:] # Lowercase [a-z]
226
+ [:upper:] # Uppercase [A-Z]
227
+ [:space:] # Whitespace [ \t\n\r\f\v]
228
+ [:blank:] # Space and tab [ \t]
229
+ [:punct:] # Punctuation
230
+ [:xdigit:] # Hex digits [0-9A-Fa-f]
231
+ [:word:] # Word characters [A-Za-z0-9_]
232
+ ```
233
+
234
+ ### Usage
235
+ ```bash
236
+ # Match any digit
237
+ grep "[[:digit:]]" file.txt
238
+
239
+ # Match any whitespace
240
+ grep "[[:space:]]" file.txt
241
+
242
+ # Match uppercase letters
243
+ grep "[[:upper:]]" file.txt
244
+ ```
245
+
246
+ ## Practical Examples for Shell Scripts
247
+
248
+ ### Log File Analysis
249
+ ```bash
250
+ # Find errors in last hour
251
+ grep "$(date -d '1 hour ago' '+%Y-%m-%d %H')" /var/log/app.log | grep -i error
252
+
253
+ # Count error types
254
+ grep -i "error" logfile.log | cut -d: -f2 | sort | uniq -c | sort -rn
255
+
256
+ # Extract IP addresses
257
+ grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' access.log
258
+ ```
259
+
260
+ ### Configuration Validation
261
+ ```bash
262
+ # Find uncommented lines in config
263
+ grep -v "^#" config.file | grep -v "^$"
264
+
265
+ # Check for specific settings
266
+ if grep -q "debug = true" config.ini; then
267
+ echo "Debug mode is enabled"
268
+ fi
269
+ ```
270
+
271
+ ### Code Search
272
+ ```bash
273
+ # Find function definitions
274
+ grep -n "^function " script.sh
275
+
276
+ # Find TODO comments
277
+ grep -rn "TODO" --include="*.sh" .
278
+
279
+ # Find unquoted variables (simple check)
280
+ grep -n '\$[A-Za-z_][A-Za-z0-9_]*\s' script.sh
281
+ ```
282
+
283
+ ## Performance Tips
284
+
285
+ ### 1. Use -F for Fixed Strings
286
+ ```bash
287
+ # Faster when not using regex
288
+ grep -F "literal string" large_file.txt
289
+ ```
290
+
291
+ ### 2. Use -q When Only Checking Existence
292
+ ```bash
293
+ # Don't need output, just exit code
294
+ if grep -q "pattern" file.txt; then
295
+ echo "Found"
296
+ fi
297
+ ```
298
+
299
+ ### 3. Limit Search Depth
300
+ ```bash
301
+ # Don't recurse too deep
302
+ grep -r --max-depth=2 "pattern" /path
303
+ ```
304
+
305
+ ### 4. Exclude Unnecessary Directories
306
+ ```bash
307
+ grep -r --exclude-dir={.git,.svn,node_modules} "pattern" .
308
+ ```
309
+
310
+ ## Exit Codes
311
+
312
+ - **0**: Match found
313
+ - **1**: No match found
314
+ - **2**: Error occurred
315
+
316
+ ## Common Pitfalls in Shell Scripts
317
+
318
+ ### 1. Not Quoting Patterns with Spaces
319
+ ```bash
320
+ # Wrong
321
+ grep $pattern file.txt
322
+
323
+ # Right
324
+ grep "$pattern" file.txt
325
+ ```
326
+
327
+ ### 2. Using grep in Tests Without -q
328
+ ```bash
329
+ # Inefficient
330
+ if [ "$(grep pattern file)" ]; then
331
+
332
+ # Better
333
+ if grep -q pattern file; then
334
+ ```
335
+
336
+ ### 3. Useless Use of cat
337
+ ```bash
338
+ # Wrong (UUOC)
339
+ cat file | grep pattern
340
+
341
+ # Right
342
+ grep pattern file
343
+ # or
344
+ < file grep pattern
345
+ ```
346
+
347
+ ### 4. Not Handling No Match Case
348
+ ```bash
349
+ # grep returns 1 if no match, can cause set -e to exit
350
+ grep "pattern" file || true
351
+
352
+ # Or check explicitly
353
+ if grep -q "pattern" file; then
354
+ echo "Found"
355
+ else
356
+ echo "Not found"
357
+ fi
358
+ ```
359
+
360
+ ### 5. Forgetting to Escape Regex Metacharacters
361
+ ```bash
362
+ # Wrong - . matches any character
363
+ grep "192.168.1.1" file
364
+
365
+ # Right - escape the dots
366
+ grep "192\.168\.1\.1" file
367
+
368
+ # Or use -F for literal match
369
+ grep -F "192.168.1.1" file
370
+ ```
371
+
372
+ ## Useful Combinations
373
+
374
+ ```bash
375
+ # Case-insensitive recursive search with line numbers
376
+ grep -rni "pattern" /path
377
+
378
+ # Count total matches across files
379
+ grep -r "pattern" . | wc -l
380
+
381
+ # Find and highlight matches
382
+ grep --color=always "pattern" file.txt | less -R
383
+
384
+ # Search compressed files
385
+ zgrep "pattern" file.gz
386
+
387
+ # Search with extended regex and only show matches
388
+ grep -Eo "pattern" file.txt
389
+ ```
390
+
391
+ ## Resources
392
+
393
+ - [GNU grep Manual](https://www.gnu.org/software/grep/manual/)
394
+ - [grep(1) Linux Man Page](https://man7.org/linux/man-pages/man1/grep.1.html)
395
+ - [Regular Expressions in grep](https://www.gnu.org/software/grep/manual/html_node/Regular-Expressions.html)