Reputation: 63
I have a file which has data in the format
A=1234
B=3456
C=5689
Now sometimes there might not be variable values with the variables
i.e.
A=1234
B=2566
C=
D=555
I want to delete the lines in which there is nothing after "=".
What sed command can i use to achieve it?
Upvotes: 1
Views: 189
Reputation: 786291
Following sed should work:
sed -n '/= *$/!p' file
EDIT: To save these changes back to the file, use inline flag -i
:
sed -i.bak -n '/= *$/!p' file
To delete blank lines with 0 or more spaces:
sed -i.bak -rn '/= *$|^ *$/!p' file
Upvotes: 1
Reputation: 98118
Delete the line if there is nothing except possible whitespace after the =
:
sed '/=[ ]*$/d' input
Upvotes: 1