Find count of files matching a pattern in a directory in linux

前端 未结 6 1334
面向向阳花
面向向阳花 2021-02-02 09:06

I am new to linux. I have a directory in linux with approx 250,000 files I need to find count of number of files matching a pattern.

I tried using following command :

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-02 10:05

    you got "argument too long" because shell expands your pattern to the list of files. try:

    find  -maxdepth 1 -name '20061101-20131101_kh5x7tte9n_2010_*' |wc -l
    

    please pay attention - pattern is enclosed in quotes to prevent shell expansion

提交回复
热议问题