acer
acer

Reputation: 303

Escape character for $ in Bash file

I need to create a bash file to rename files,where I need to have filename with $ symbol.

Eg:- Na$me

how can I escape this $ symbol, / is not working to escape $ symbol

Upvotes: 2

Views: 79

Answers (1)

John1024
John1024

Reputation: 113844

There are two ways to deactivate $ in shell:

  1. You can use single-quotes:

    $ var='Na$me'; echo "$var"
    Na$me
    
  2. You can use a backslash:

    $ var=Na\$me; echo "$var"
    Na$me
    

Upvotes: 6

Related Questions