?
Solved

Syntax error at line 4 : `<<' is not matched

Posted on 2003-03-24
5
Medium Priority
?
1,271 Views
Last Modified: 2013-12-27
Dear experts,

I am trying to write a shell script to include a line in file.
There are many files that I need to include the line "connect internal".
I have pasted below a sample of the script:
*****************************
for j in `ls *.txt`
do
 ed -s /tmp/unix.txt<<EOF
 H
 f
 $ i
 connect internal
 .
 w
 EOF
done

*****************************
Whenever I execute the above script I get the message:

stv10750:/tmp# > ./modifyscript.sh
./modifyscript.sh[2]: Syntax error at line 4 : `<<' is not matched.

Could you please help me in this.

Many thanks
Mike
0
Comment
Question by:miker123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:SumeshDaftary
ID: 8196905
Your 4th line says

H only

What it means (as per your idea)

0
 
LVL 5

Expert Comment

by:ecw
ID: 8198902
Make sure there are no spaces before or after EOF.
0
 
LVL 2

Accepted Solution

by:
soupdragon earned 225 total points
ID: 8199401
I don't see the variable $j used in your code snippet and I'm not sure you can pass a variable into ed. If you just want to add text at the end of each file use echo.

for j in `ls *.txt`
do
echo "connect internal" >>$j
done

0
 
LVL 5

Expert Comment

by:ecw
ID: 8199840
The variable is not being passed into ed.  The variable is expanded by the shell before the contents of the here document are passed to ed.  If <<EOF was <<"EOF" or <<'EOF' the variable would not be evaluated.
0
 
LVL 4

Expert Comment

by:Otetelisanu
ID: 8200654
For and after EOF must by no
spaces
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question