"sed" command fails when the file path has $(dollar sign) in it #2584

Resolved 💬 2 comments Opened Aug 22, 2025 by hlthi Closed Dec 12, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.23.0

Which model were you using?

gpt-5-mini

What platform is your computer?

Darwin 25.0.0 arm64 arm

What steps can reproduce the bug?

Create a file whose name contains a $ character:

touch myfilename.$otherpartname.tsx

(Example dynamic route used in TanStack Router)
Try to process/read the file with a CLI command, for example:
Bash

sed -n '1,360p' myfilename.$otherpartname.tsx
````





### What is the expected behavior?

The command should read/process the file normally, with the $ treated as a literal part of the file name.

### What do you see instead?

The command fails or returns incorrect output. The $ is being interpreted by the shell as a variable reference, so the CLI cannot find or correctly read the file.

  └ ⌨️ sed -n '1,360p' src/routes/x.$y.tsx
    /opt/homebrew/Library/Homebrew/cmd/shellenv.sh: line 18: /bin/ps: Operation not permitted
    sed: src/routes/x..tsx: No such file or directory

### Additional information

In most shells, $ is a special character used for variable expansion.
The CLI likely needs to quote or escape file paths before executing commands to handle such filenames correctly.

Just escape !

View original on GitHub ↗

2 Comments

DanielNagy · 11 months ago

I've seen similar problems, because i have (protected) in the path, as a quick work around, i've added some CLI Tips to AGENTS.md with the following. Basically to tell it to quote paths.

CLI Tips

  • Quote paths that include parentheses when running shell commands (for example rg "ManagedTenantUser" 'apps/web/app/(protected)/admin/page.tsx') to avoid syntax error near unexpected token '('.
etraut-openai contributor · 8 months ago

I think this bug report is stale, so I'm going to close it out. If you're still seeing this behavior, let us know.