Rafael
Rafael

Reputation: 133

Replace line with command sed

I want to replace a line in a file, but I'm kinda lost with the command line.

Here's the specific line I want to change; line 55 of a PHP file:

$response['data']['responseData']['ballonsftver'] = @constant('BALLON_VER');

I want to replace for this:

$response['data']['responseData']['ballonsftver'] = "2.1-0";

How do I use sed to replace that line?

Thanks

Upvotes: 0

Views: 66

Answers (1)

yausername
yausername

Reputation: 760

This will replace @constant('BALLON_VER') on line 55 with "2.1-0"

sed -i 55s/"@constant('BALLON_VER')"/"\"2.1-0\""/ filename

Careful while using -i switch of sed to perform an in-place editing.

Upvotes: 3

Related Questions