Jürgen Paul
Jürgen Paul

Reputation: 14997

Find and replace string in parameter bash

$ ./myscript my.site.com

How do I replace all dots in the first parameter? Here's my current try but it's returning a bad substition error.

#!/bin/bash
dbname=${$1//./_}

echo $dbname

Upvotes: 7

Views: 1520

Answers (1)

Prince John Wesley
Prince John Wesley

Reputation: 63688

dbname=${1//./_}

Remove $ before 1 since $1 and ${1} are the same.

Upvotes: 12

Related Questions