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

后端 未结 5 588
礼貌的吻别
礼貌的吻别 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:31

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

    Does not work for me. It return nothing. If I just do '.' it gives me all the files in directory below the one I'm working in on.

    find /dev -maxdepth 1 -name "*.root" -type 'f' -size +100k -ls
    

    Return nothing with '.' instead I get list of all 'big' files in my directory as well as the rootfiles/ directory where I store old ones.

    Continuing. This works.

    find ./ -maxdepth 1 -name "*.root" -type 'f' -size +100k -ls
    564751   71 -rw-r--r--   1 snyder   bfactory   115739 May 21 12:39 ./R24eTightPiPi771052-55.root
    565197  105 -rw-r--r--   1 snyder   bfactory   150719 May 21 14:27 ./R24eTightPiPi771106-2.root
    565023   94 -rw-r--r--   1 snyder   bfactory   134180 May 21 12:59 ./R24eTightPiPi77999-109.root
    719678   82 -rw-r--r--   1 snyder   bfactory   121149 May 21 12:42 ./R24eTightPiPi771098-10.root
    564029  140 -rw-r--r--   1 snyder   bfactory   170181 May 21 14:14 ./combo77v.root
    

    Apparently /dev means directory of interest. But ./ is needed, not just .. The need for the / was not obvious even after I figured out what /dev meant more or less.

    I couldn't respond as a comment because I have no 'reputation'.

提交回复
热议问题