- cross-posted to:
- [email protected]
- [email protected]
- cross-posted to:
- [email protected]
- [email protected]
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
grep -r
exists and is even more faster and doesn’t require passing around file names.grep -r --include='*.txt' 'somename' .
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
This does not need to be a 8 minute video. Read your tldw instead. Thanks, OP.
Better than the video thank you, I didn’t watch the video
Then you dont know how the video is :D
Not the person above, but I know that written explanations of command line tools are always preferred by myself.
No, no, you just need to seek through the time and copy & paste the text in the video!
Why didn’t I think of that? This is a game changer!
I know it’s 8 minutes long.
Skip to 2:46 how she also mentioned in the description
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.
I have rg installed but only used it for basic grep replacement
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…Her presentations are fun. Thanks! Great watch.
I prefer to watch videos via peertube, not youtube, whenever possible. She has a peertube channel so here is the same video there: https://tinkerbetter.tube/w/g8K2zBgwwwE1xukkT6EmSo
It is important to have backups for when Youtube blocks clients, but I just watch it over a VPN and Freetube or Grayjay. Not leeching any resources when avoidable, just costing big brother money.
You’re giving all your data to your VPN company, though
True. But I pay them via Monero
And give no personal information? Like Mullvad? That is an improvement.
Yup. Also their VPN app on Linux is better than what KDE and GNOME have. Poorly. They hook into it very intensely, early boot blocking via a systemd service and all.
She’s done such a good job with this channel. I understand most of the content, but I always pick up a nugget of new as well as being able to better explain after a topic she ELI5’d
If you have a very large directory, find will check each individual file, even when
-path
doesn’t match, which makes it take longer to complete. Combine-o
and-prune
to omit them entirely.find . -path '**/node_modules/**' -prune -o -type f -name '*.js' -exec grep 'import' {} +
Forgive me for only TLDW and not watching, but was ack mentioned?
I’ve never looked back.
When using both
{}
and;
, it’s safer to use single quotes to escape the current argument and ending delimiter; eg’{}’
and’;’
, respectively.Why? The quotes will be consumed by the shell when you execute the command, unless you do like
"'{}'"
Here is an alternative Piped link(s):
https://piped.video/watch?v=FvEoGHFKsKA
Piped is a privacy-respecting open-source alternative frontend to YouTube.
I’m open-source; check me out at GitHub.
Thank you for the TL;dw. Sincerely appreciated.
deleted by creator