How to list specific type of files in recursive directories in shell?

后端 未结 7 867
無奈伤痛
無奈伤痛 2021-01-31 15:26

How can we find specific type of files i.e. doc pdf files present in nested directories.

command I tried:

$ ls -R | grep .doc

but if th

7条回答
  •  忘掉有多难
    2021-01-31 15:40

    Similarly if you prefer using the wildcard character * (not quite like the regex suggestions) you can just use ls with both the -l flag to list one file per line (like grep) and the -R flag like you had. Then you can specify the files you want to search for with *.doc I.E. Either

    ls -l -R *.doc
    

    or if you want it to list the files on fewer lines.

    ls -R *.doc
    

提交回复
热议问题