-1

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

Madhav
  • 41
  • 6

1 Answers1

0

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
Raman Sailopal
  • 12,320
  • 2
  • 11
  • 18