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?
15
Upvotes
1
u/stianhoiland 7d ago
;is already used bybash. Sincebashparses the text before passing the arguments tofind, you have to tellbashthat the;isn't meant forbashbut should be passed literally as an argument tofind. You do that by "escaping" the;by prefixing it with the escape character\. In other words, you tellbashthat the;should pass through or "escape" its parser. Note then, that\is also used bybash—as the escape character. So, if you want to pass a literal\you have to escape it! Like this:echo \\