Originally Posted by pixellany
If you mean "lines" when you say "registers", then it works fine here. Note that the "g" has no function because you are matching only once--ie at the end of the line.
Another way of doing the same thing:
sed '/;$/s/$/NULL/' filename
If you have data in multiple columns, then you may need something like AWK.
Please post an example of the data, and what is not working correctly.
Thanks. I am making a script for parsing a raw file text with database registers into a file with INSERT INTO sql instructions.
The plain text document may have something like this:
id;name;last name; address; telephone; cellphone; email
Some of the atributes may have null values, like this:
In this case I need to fill with the word NULL the null fields so I can later create an INSERT INTO sql instruction later on (using awk), such like this:
I have been able to insert every NULL string except for the one at the end.
The problem is that when I use both commands I am still getting
1;... ; instead of 1; .... ;NULL