Reputation: 1246
I have file that has data that looks like this:
$table_prefix = 'wp_';
'
$more_stuff = 'ab_';
'
where randomly there is a single quote on a line by itself. I'm struggling on how to remove this while not impacting the other quotes?
I've tried sed:
sed -i -z "s/'\n/""/g" wp-config.php
Looking for ' and newline and then replacing with nothing or I don't mind if it's even replaced with a space.
Upvotes: 1
Views: 62
Reputation: 18611
Use
sed -i 's/\r$//g' wp-config.php
sed -i "/^'$/d" wp-config.php
sed -i 's/\r$//g' wp-config.php
- removes all carriage return characters that have a line feed after themsed -i "/^'$/d" wp-config.php
- removes all lines with standalone apostrophes.Upvotes: 0
Reputation: 99084
sed -i "s/^'$//" wp-config.php
or
sed -i "/^'$/d" wp-config.php
(I advise you to try it without -i
first, to make sure it does what you expect in your version of sed.)
Upvotes: 1