Learning about xargs was fun... Point me at more UNIX things that I might not know?

@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 '{}' +

@aescling Wait. Should I be quoting the {}? I genuinely forgot... (Also, does the command you just wrote not need a \; at the end, after the +?)

@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

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.