0

I am creating a test.sh file and i am running it as ./test.sh:

string="hello"
ed << EOF
e any_file
1i
${string}
EOF

can anybody help me what it does?

I am getting some delimiter issue. Can anybody tell me how to do this?

1
  • 1
    What does “some delimiter issue” mean? Copy-paste any error message. Also post a complete script that reproduces the problem (again, copy-paste). Feb 12, 2014 at 22:49

1 Answer 1

2

your script is incomplete, as it misses the terminating EOF literal.

i try to explain the script:

the first line simply assigns "hello" to the variable string.

 string="hello"

the 2nd line starts the ed command, and feeds it (via stdin) the following lines until it encounters the EOF literal (<< foo means: the following lines until foo are redirected to the stdin)

 ed << EOF

the following lines are ed commands.

open a file called *any_file* (e any_file), and insert 1i the string ${string} (this will be expanded to "hello").

but since you are missing the terminating EOF literal, the stdin-redirection throws an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.