EOF

Asked by yastackman

ProblemType: Bug
DistroRelease: Ubuntu 10.04LTS
Emulator: GNOME 2.29.6
SHELL=/bin/bash
HOME=/home/fujimon

When I use 'sed-i' from the commandline , I push ctrl-c on my keyboard with command not enclosed by the right double

quotation mark `"' ,

After this , error message described below appears ;

fujimon@fujimon-desktop:~$ sed -i "1 i \

> ^C
fujimon@fujimon-desktop:~$ sed -i "1 i \

> bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

I am not able to edit new text document file made in home directory and deeper directory using 'sed -i' from commandline.

But,I can edit new text document file using gedit.

Please help me.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu sed Edit question
Assignee:
No assignee Edit question
Solved by:
Ralph Corderoy
Solved:
Last query:
Last reply:
Revision history for this message
David Mawdsley (dm-madmod) said :
#1

Sed is not a simple command. I would suggest that you strart by studying the information about sed at the terminal command.
man sed

Also set your browser to: http://www.grymoire.com/Unix/Sed.html#uh-0
and try their examples.

I'm not really able to understand what you're trying to do. sed-i isn't useful. sed -i should give you information on sed.

Using backticks such as: ` usually require them in pairs to enclose a command.

Perhaps another person can give you more useful information regarding what you're trying to do.

Revision history for this message
yastackman (fujimon19841226) said :
#2

I appriciate your advice on my trouble. I will study more about 'sed' command .

Revision history for this message
Best Ralph Corderoy (ralph-inputplus) said :
#3

Hi yastackman,

I can only re-produce what you see by typing Ctrl-D which is normally
the tty's end of file, EOF, character. The error message is correct
because bash is trying to find the end of the double-quoted string you
started but it isn't there.

I think David was confused when he mentions backticks, you weren't using
them, merely quoting a double quote in a back and forward single quote,
like I do: `"'.

Here's some examples of inserting and -i. The first uses single quotes
to protect the sed script from the shell's interpretation. The second
uses double quotes. That means every backslash I want sed to see needs
doubling, but it does allow variables like $TERM to be specified and
have their expansion be passed to sed. Which to use depends on your
needs.

    $ seq 3 >foo
    $ cat foo
    1
    2
    3
    $ sed -i '1i\
    > First example,\
    > ends here.
    > ' foo
    $ cat foo
    First example,
    ends here.
    1
    2
    3
    $ sed -i "1i\\
    > Second example,\\
    > allowing things like $TERM.
    > " foo
    $ cat foo
    Second example,
    allowing things like xterm.
    First example,
    ends here.
    1
    2
    3
    $

Revision history for this message
yastackman (fujimon19841226) said :
#4

Hi Mr. Ralph ,
 I appriciate your advice .
  I've found new text file which I want to edit by sed without a carriage-return key pushed.
Therefore sed did'nt recognize imput file at all and that's why I could not edit new text file using sed from commandline.
I was careless. ><
I will be careful not to make mistake like this again.

Thank you for replying, Mr. Ralph and Mr. David.