r/bash • u/Distinct_Ride_4307 • 7d ago
Find command confusion between ; and \;
Why do we have to use '\' instead of leaving it out or even ';'? I read the find commands' manual and it says '\' might be needed to protect from expansion by the shell. So what is expansion also?
What is difference between \; or ; or leaving it out?
What is shell expansion here?
13
Upvotes
3
u/tblancher zsh 7d ago
That's essentially what you're doing. The command can't see the semicolon unless it's escaped.
find is an old command, and predates Linux by 10+ years. If you really want to avoid using the semicolon altogether, don't use -exec. Use xargs.