bash

Ignoring the Dollar Sign ($) Prefix in Bash Scripts

This article introduces how to ignore the "$" at the beginning of Bash scripts on Linux PC/server command lines. Many websites write "$" at the beginning when introducing Linux commands. However, this naturally results in a "$: command not found" error. To avoid this, you need to delete or replace the "$" each time, but...

Shou Arisaka
1 min read
Oct 30, 2025

This article introduces how to ignore the ”$” at the beginning of Bash scripts on Linux PC/server command lines.

Many websites write $ at the beginning when introducing Linux commands. However, this naturally results in a $: command not found error.

To avoid this, you need to delete or replace the $ each time, but that’s tedious.

So,

If the beginning of an entered command is $, wouldn’t it be good if we could ignore the $? Is that possible?

https://stackoverflow.com/questions/45213240/ignore-at-the-beginning-of-the-command-in-bash?answertab=votes#tab-top

…I asked this question, and the answer is as follows:

  • Make `$` recognized as a command and ignore it.
```bash # Add `$` file under $PATH

nano /usr/local/bin/$ #!/bin/bash exec ”$@“

Permission

chmod 755 /usr/local/bin/$

I asked this question about two years ago, but looking at it now, it's not that complicated. You could use a function instead of a file.

Share this article

Shou Arisaka Oct 30, 2025

🔗 Copy Links