What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
In Bash, either escape the space with a backslash or put the filename in quotes. For a file named My File.txt, both commands pass one filename argument:
cat My File.txt
cat 'My File.txt'
The backslash and quote marks are shell syntax; they do not become part of the filename. These examples describe Bash behavior, not a change to how Linux stores the name.
As an Amazon Associate I earn from qualifying purchases.
Why an unquoted space causes trouble
Bash treats spaces and tabs as word separators. Without quoting or escaping, it splits My File.txt into two words—My and File.txt—and passes them as separate arguments to the command. Bash processes quoting before word splitting and filename expansion, which is why protecting the space keeps the filename together. See the Bash manual’s shell syntax definitions and its description of shell expansions.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallChoose a backslash or quotes
| Form | Example | Use it when | Watch for |
|---|---|---|---|
| Backslash escape | cat My File.txt |
You are typing a short, literal command. | Escape each character that needs protection; long names are easy to mistype. |
| Single quotes | cat 'My File.txt' |
You want the enclosed text treated literally. | A single quote cannot appear directly inside a single-quoted string. |
| Double quotes | cat "My File.txt" |
You need spaces grouped while retaining selected shell expansions. | $ and backticks still have special meaning, and backslash remains significant in specific cases. |
For a simple filename, the backslash form is compact; single quotes are often clearer for literal text. Bash’s manual explains that an unquoted backslash preserves the next character’s literal value, except newline, and that single quotes preserve the literal value of enclosed characters. Double quotes group words but are not fully literal. Read the manual’s sections on quoting and single quotes.
#1 Best Overall
Quote variable expansions in scripts
If a variable contains a filename with spaces, put the quotes around the expansion where you use it:
file='My File.txt'
cat "$file"
The quotes around "$file" keep its value together as one argument and prevent wildcard characters in the value from triggering filename expansion. Putting quote characters inside the variable’s value does not make them active shell syntax when the variable expands. Bash describes these expansion rules in its sections on double quotes and shell expansions.
When a filename contains a single quote
A single quote cannot be written directly inside a single-quoted segment. Bash lets you join quoted and escaped segments to represent it. For example, this prints the text a'b:
printf '%sn' 'a'''b'
The command consists of a single-quoted a, an escaped single quote, and a single-quoted b. For complicated names, shell completion can reduce manual typing. If copying names from command output, do not assume every tool prints shell-ready text. GNU Coreutils documents shell-oriented quoting modes and notes that its output is suitable for POSIX-compatible shells such as Bash but may not work in incompatible shells such as csh; see the Coreutils manual on quoting.
What the escape characters do—and do not do
The filename itself contains an ordinary space. Bash removes the quoting syntax during command processing, so the command receives the original filename characters as one argument. These instructions are for Bash and compatible command lines; other shells can have different quoting rules. The GNU Bash Reference Manual edition 5.3 was last updated 18 May 2025.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




