I want to do a Sourcegraph search and have it show only results from files with a certain extension.
How do I filter by file type on Sourcegraph?
7k Views Asked by felixfbecker At
2
There are 2 best solutions below
0

I wanted to search drizzle
migration commands in bash
script that ends in .sh
extension so I used:
drizzle file:\.sh$
\
is used to escape the .
while $
signifies the end of the string. So .sh
is surrounded by \
& $
.
Works for other languages as well:
\.js$
- JavaScript\.ts$
- TypeScript\.jsx$
or\.tsx
- JSX\.py$
- Python
You can use the
file:
token to filter results by filename regex. For example,file:\.go$
would limit results to files ending in ".go".The full search query syntax is documented here: https://docs.sourcegraph.com/code_search/reference/queries