linux - Select files by extenstion using grep -


i need count .txt files in current folder. tried ls | grep .txt if folder content is: a.txt btxt c.c select a.txt , btxt , want files end .txt. tried various combinations of regexp no result.

find may better in case since designed handling file names:

find . -maxdepth 0 -name '*.txt' | wc -l 

buf if cautious possibly strange file names:

find . -maxdepth 0 -name '*.txt' -exec echo 1 \; | wc -l 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -