Surface-attached cells can sense and respond to shear flow, but planktonic (free-swimming) cells are typically assumed to be oblivious to any flow that carries them. Here, we find that planktonic bacteria can transcriptionally respond to flow, inducing expression changes that are beneficial in flow. Specifically, we use microfluidic experiments and quantitative modeling to show that in the presence of flow, planktonic Pseudomonas aeruginosa induce shear rate-dependent genes that promote growth in low-oxygen environments. Untangling this mechanism revealed that in flow, motile P. aeruginosa spatially redistribute, leading to cell density changes that activate quorum sensing, which in turn enhances the oxygen uptake rate. In diffusion-limited environments, including those commonly encountered by bacteria, flow-induced cell density gradients also independently generate oxygen gradients that alter gene expression. Mutants deficient in this flow-responsive mechanism exhibit decreased fitness in flow, suggesting that this dynamic coupling of biological and mechanical processes can be physiologically significant.