If I have the following text within a file (somefile.txt):
CREATE TABLE "table_name" (
"id" int(11) unsigned NOT NULL,
"some_field" varchar(10),
);
CREATE TABLE "another_table" (
"id" int(11) unsigned NOT NULL,
"some_other_field" varchar(10),
);
I want to remove the last trailing comma in each statement, so that it becomes:
CREATE TABLE "table_name" (
"id" int(11) unsigned NOT NULL,
"some_field" varchar(10)
);
CREATE TABLE "another_table" (
"id" int(11) unsigned NOT NULL,
"some_other_field" varchar(10)
);
I've used the regular expression \,$\n\) but I can't seem to get this to work with sed, which throws:
sed: -e expression #1, char 23: Unmatched ) or \)
when I use:
sed -i -e 's/\,$\n\)/)/g' somefile.txt