Its frequent acidity and high osmolality are inhibitory for many microbes. In the rabbit, the transitional epithelial cells of the urinary bladder exert an antibacterial effect. How this is done and whether it is also true of humans is still not confirmed. A recent paper from China, however, claimed isolation of a human urinary mucosal protein that inhibited E. coli. Bile flushes the biliary tree and gallbladder.
Bile salts inhibit many kinds of bacteria, especially gram positives.
Both lysozyme and lactoferrin are found in bile, presumably secreted by the peribiliary glands. Peristalsis moves the entire contents of the gut to the external environment in a kind of slow motion flush. Many microbes cannot surive that kind of acid treatment, although some manage, apparently by being embedded in food particles where the acid can't reach them. Helicobacter pylori, a cause of chronic gastritis, secretes urease, which hydrolyzes urea into ammmonia. Presumably that neutralizes the HCl in the immediate vicinity of the bacterial cell.