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
57 points

grep -r exists and is even more faster and doesn’t require passing around file names.

grep -r --include='*.txt' 'somename' .
permalink
report
reply
3 points
*

Or use strings if you want clean binary results. (Grep can probably do this, too)

Edit: Yes, with -b, also -R follows symlinks unlike -r

permalink
report
parent
reply
38 points

This does not need to be a 8 minute video. Read your tldw instead. Thanks, OP.

permalink
report
reply
21 points

Better than the video thank you, I didn’t watch the video

permalink
report
reply
15 points

Then you dont know how the video is :D

permalink
report
parent
reply
28 points

Not the person above, but I know that written explanations of command line tools are always preferred by myself.

permalink
report
parent
reply
8 points

No, no, you just need to seek through the time and copy & paste the text in the video!

permalink
report
parent
reply
9 points

I know it’s 8 minutes long.

permalink
report
parent
reply
0 points

Skip to 2:46 how she also mentioned in the description

permalink
report
parent
reply
19 points
*

Just for the sake of completeness:

https://github.com/BurntSushi/ripgrep

https://github.com/ggreer/the_silver_searcher

It’s useful to be able to do this without additional tools (and there are more applications for the general command setup discussed in the video), but in practice, ease of use and performance often make a difference.

permalink
report
reply
1 point

I have rg installed but only used it for basic grep replacement

permalink
report
parent
reply
11 points

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…

permalink
report
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 9.6K

    Monthly active users

  • 5.8K

    Posts

  • 162K

    Comments