How to only find files in a given directory, and ignore subdirectories using bash

后端 未结 5 586
礼貌的吻别
礼貌的吻别 2021-01-30 05:45

I\'m running the find command to find certain files, but some files in sub-directories have the same name which I want to ignore.

I\'m interested in files/pa

5条回答
  •  孤城傲影
    2021-01-30 06:36

    If you just want to limit the find to the first level you can do:

     find /dev -maxdepth 1 -name 'abc-*'
    

    ... or if you particularly want to exclude the .udev directory, you can do:

     find /dev -name '.udev' -prune -o -name 'abc-*' -print
    

提交回复
热议问题