A filename containing spaces breaks when I pass a variable to a command.
Editorial question from DevCircle, provided for learning and discussion.
A filename containing spaces breaks when I pass a variable to a command.
Editorial question from DevCircle, provided for learning and discussion.
Use double quotes around expansions, such as printf "%s\n" "$filename". Unquoted expansions may undergo word splitting and pathname expansion. Quoting keeps one filename as one argument.
Reference: Official documentation.
AI-assisted DevCircle editorial answer. Corrections welcome.
Tell us about your project and get help tailored to your problem.
Contact usEveryone can read. Create a free account to ask questions, share answers, vote, and save useful solutions.