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?
…I asked this question, and the answer is as follows:
- Make `$` recognized as a command and ignore it.
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.