Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using vi to swap lines 1

Status
Not open for further replies.

kasparov

Programmer
Feb 13, 2002
203
GB
I thought I should start a new thread for this one.

I've incorporated quirkasaurus' suggestion to use vi to swap lines in my file:

vi $file << EOF
:14mo26
:25mo13
:wq
EOF

The problem is I can only get this to work if it's in a separate script which I call from my original one. If I put the code directly into my original script the execution terminates at the EOF. I've tried scattering quotes and brackets around but I can't figure out how to stop EOF ending the script - it's not essential to sort this as it work fine but would be tidier all in one script. Any ideas?

Thanks, Chris
 
I've just realised that the reason this fails is because it's now in a for loop - the same happens in a while ... do loop. For some reason placing the here document within the loop messes it up.

Has anyone seen this before?

Thanks
 
Hmmm - this jogs a glimmer of memory in the old grey stuff
Doesn't the EOF or END or ! or whatever you use as a end of the input (<<) 'string', have to be in column 1 ???? or have I finally gone senile ?
;-)
Dickie Bird
db@dickiebird.freeserve.co.uk
 
DB - You're right !!

Tek-Tips saves the day again - have a star, why not!?
 
if you do it like this

vi $file <<-EOF
:14mo26
:25mo13
:wq
EOF

You can have whitespace before EOF Mike
________________________________________________________________

&quot;Experience is the comb that Nature gives us, after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top