728x90
13
5
I'd like to find source files (*.c, *.cpp, *.h) that contain in Linux/MinGW/Cygwin, and recursively in all sub directories.
My basic idea is using find
and grep
. However, building a regular expression that can check given file name is either *.c, *.cpp, or *.h isn't easy. Could you help me out?
add a comment
12
This should work:
find Linux/MinGW/Cygwin -name '*.c' -o -name '*.cpp' -o -name '*.h'
1
I would use:
find . -regex '.*\.\(c\|cpp\|h\)$' -print
- 1In my macbook, the script without a
-E
can't find anything. you might need add a -E (as extended) to make it more portable, just likefind -E . -regex '.*\.(c|h|cpp)' -print
. ;-) – YanTing_ThePandaMay 1 '17 at 9:17
1
Quick and dirty, and avoids directory names:
find . -type f -name *.[c\|h]
- 2There are three problems with this command: 1. It won't find
*.cpp
files. 2. It will find*.|
files. 3. The glob will expand if there are matching files in the current directory. Quoting prevents that. – Dennis Dec 17 '13 at 15:48
0
I use a mac pro which also works in bash. But every time I type in the command line:
find -name
it says illegal option. So I just simplified it as:
find *.c *.cpp *.h
and found it really worked!
0
You can use a slightly simpler regex:
find . -type f -regex ".*\.[ch]\(pp\)?$"
'PENTEST' 카테고리의 다른 글
How to install Nessusd in Kali linux (0) | 2019.03.10 |
---|---|
Scan Websites for Potential Vulnerabilities Using Vega in Kali Linux (0) | 2019.03.10 |
NSA has Open Sourced its Reverse Engineering Tool Ghidra (0) | 2019.03.08 |
CentOS 7 - PermitRootLogin (0) | 2018.05.06 |
php-reverse-shell (0) | 2018.04.24 |
$
at the end of the command do? – Ali Aug 15 '17 at 3:16foo.cpp.old
for example). – Dennis Williamson Aug 23 '17 at 13:12