@vaporeon_ do you know find? purrticularly -exec?
@aescling Barely 😓
I know find some-directory -name '*.txt (or -iname for case-insensitive, also substitute whatever other globbing expression instead of *.txt, just don't forget the quotes), I know find -print | less (this is what I use to use to look at a tree of files), I know find -exec some-command {} \;, where {} will get substituted with the filename. I've used it with grep before to get a list of files (just the filenames, not all occurrences) that contain a particular string.
I vaguely remember there also was some other variant of exec where you could specify multiple files? With + or something? But I completely forgot :(
@vaporeon_ fur using multiple arguments in the same command you just add a + after the {}, e.g., find . -type f -exec grep pattern '{}' +
@vaporeon_ it's shell syntax, so yes
@aescling Doesn't work for me in Bash, needs to be { echo hi; cat file; } >file2 for it to work... ( echo hi; cat file ) >file2 works, though... Can you tell me what the difference between these and the other brackets is? I don't know...
@vaporeon_ god i keep furgetting when the final semicolon is necessary
{} runs the commands in the current shell; () runs them in a subshell
if you can spare the extra purrocess,
(
cd dir
[...]
)
is a convenient pattern
@aescling What happens if I don't? I just attempted to execute find . -type f -exec grep -H abcd {} \; on a directory containing files that have whitespaces in their names, and it still worked fine...
@vaporeon_ really? i’m pretty sure that should be a syntax error. huh
@vaporeon_