TL;DW

# find with grep
# + concatinates results and runs the command once, faster
find . -name "*.txt" -exec grep -l "somename" '{}' '+'

# run a command for each result individually
find . -name "*.txt" -exec basename '{}' \';' |  column

# case insensitive
find -iname "SoMeNaMe.TxT

# file or dir
find -type f
find -type d

# define file owner
find -user Bob

# define file group
find -group wheel

# by permission
find -perm 777

# find by size
find -size +1G
  • qjkxbmwvz@startrek.website
    link
    fedilink
    arrow-up
    11
    ·
    7 months ago

    I kinda prefer xargs to the -exec option — just feels more UNIXy to me (do one one job well).

    But as another comment said, for grep I just use -r and --include. So clearly I’m not very consistent…