I was wondering if there is a way to ls
files in a folder that does not have a given extension? For example, if I have a folder full of .cpp
and .h
files, and I wanted to see if there are other types of files (such as config files and make files), how do I list or find?
Thanks,
你可以使用find:
find . -maxdepth 1 ! \( -name "*.cpp" -o -name "*.h" \)
shopt -s extglob
ls *!(.cpp|.h)
通过适当的grep
管道,例如:
ls | grep -Ev '\.(cpp|h)$'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.