I need to replace
DatabaseConnection.GetConnection()
with
DatabaseConnection.GetConnection(_connectionString)
Using grep (GNU grep) 3.1
grep GetConnection() CustomerRepository.cs
yields
bash: syntax error near unexpected token `('
however
grep GetConnection\(\) CustomerRepository.cs`
outputs
using (IDbConnection connection = DatabaseConnection.GetConnection())
as expected
Using sed (GNU sed) 4.8
sed -e 's/GetConnection()/GetConnection(_connectionString)/' CustomerRepository.cs
outputs the entire contents of the input file, as it does when I escape the search parentheses.
Totally lost, what do I need to do to have this work?
sed
andgrep
have different purposes - what is it that you want to do?DatabaseConnection.GetConnection()
withDatabaseConnection.GetConnection(_connectionString)
_connectionString
parameter between the parentheses.grep
command, they're protected from the shell by the single quotes, and sed's default regular expression dialect is BRE in which parentheses are not special (you would need to escape the ones on the LHS if you'd used sed's-E
or-r
options to change the dialect to ERE)sed -e 's/GetConnection\(\)/GetConnection(_connectionString)/' CustomerRepository.cs
displays the entire contents of the input file, as dosed -E..
andsed -r...
.