I tried various solution on the internet like below Example-

sed -i -e "/^gitlab_rails['omniauth_enabled']=/s|.*|gitlab_rails['omniauth_enabled']=true|" testFile.rb

but nothing seems to work.

Sample File: cat testFile.rb

Hello it is me

a = true

gitlab_rails['omniauth_enabled']=false

1

There are 1 best solutions below

0
Raman Sailopal On

Sed will see the square brackets as part of a regular expression and so these will need to be escaped. The command should therefore be:

sed -i -e "/^gitlab_rails\['omniauth_enabled'\]=/s|.*|gitlab_rails['omniauth_enabled']=true|" testFile.rb