-1

page.sql

Replace the following script

INSERT INTO `page`

by this:

INSERT INTO `page` (page_id, page_namespace, page_title, page_restrictions, page_counter, page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len) 

I am a beginer,I don't know what's wrong with this GNU Sed command on windows:

sed 's/INSERT INTO `page`/INSERT INTO `page` (page_id, page_namespace, page_title, page_restrictions, page_counter, page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len)/g'  pageC.sql > paged.sql
  • In your question, your sed script is surrounded by typographic left and right quote marks. It's possible you're writing your script in something like a word processor that automatically "corrects" these things in a way that is appropriate for prose but not for code. Make sure you're using a single quote, a.k.a. a plain apostrophe, that is not converted to a `‘` or `’` (`‘` or `’`). If this turns out to be your problem, please let me know and I'll convert it to an answer for you to accept. :) – ghoti Sep 09 '15 at 01:38
  • Thank you to point out,I don't know if it was auto corrected by notepad++ or here.But I'm sure I was not using these ones ‘ or ’. – jackbutton Sep 09 '15 at 02:53
  • 1
    What error do you get when you run it? On a Mac, the command shown works on the data shown, so the problem hinges on what happens with Windows. – Jonathan Leffler Sep 09 '15 at 02:59
  • @JonathanLeffler, For me, on a Mac using iTerm, the command did *not* work on the data when I copied and pasted (at least the version of the command before it was edited away), as my paste of unicode left- and right-single quotes was not converted to char 0x27. For reference, the error I got was `-bash: syntax error near unexpected token \`('`. Of course, now it works just fine. – ghoti Sep 09 '15 at 05:29
  • @ghoti: Better use Terminal instead of iTerm, then. It worked fine for me with that. I can't answer for what the question was; I haven't gone back to experiment. By the time I got to it, it was clean. But it could have been broken earlier. The suggestion that the error be reported remains valid; it would help diagnose the trouble. – Jonathan Leffler Sep 09 '15 at 05:31
  • Same error with Terminal using the original question. Terminal also supports Unicode paste. (Or perhaps UTF-8. At any rate, it supports paste of special characters.) – ghoti Sep 09 '15 at 05:35

1 Answers1

1

changing the whole line by a new content:

sed '/INSERT INTO `page`/ c\
INSERT INTO `page` (page_id, page_namespace, page_title, page_restrictions, page_counter, page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len)
' pageC.sql > paged.sql

Substitution of text

sed 's/INSERT INTO `page`/& (page_id, page_namespace, page_title, page_restrictions, page_counter, page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len)/' pageC.sql > paged.sql
  • no need of g unless this is a pattern that have several occurence on the SAME line (sed work per line, one at a the time by default)
NeronLeVelu
  • 9,908
  • 1
  • 23
  • 43