Using Ex editor commands in a shell script - Help!
Hi all,
I am trying to use the Ex editor and its commands in a script - more specifically within an if statement within a while loop.
Here are the basics of the loop:
FYI:
$file1 is a text file, and $file2 is another text file.
I want the second line in the elsesection to search for the string "ESI185", and then i want it to go to the next blank line and that will be where i'd like it to begin entering more text.
The problem is, once "ex $file2"is read, it then goes into the ex editor, but will not execute the search string, and therefore stays in the editor.
Any help would be appreciated.
Cheers,
Luke.
Last edited by Franklin52; 07-04-2011 at 08:25 AM..
Reason: Please use code tags for code and data samples, thank you
I've now got this:
But how would I get the echo command to echo the contents of $line to the line of $file2 that the ex commands have looked for above? (i.e. the next blank line after ESI185).
There has to be an easy way to do this, i'm probably just not thinking straight. Never the less, i'd appreciate a bit of help
Cheers,
Luke.
Moderator's Comments:
Please use [CODE] tags when posting source listings, console output, ...
It is often simpler to use the ed editor for such tasks. Suppose your original file is;
and you want to add the text line "sultan kudarat" after ESI185, here is one easy way of doing it:
Hi Folks -
Is there a way to add two execs to one script? For instance, I need to redirect the stdout and stderr to two separate directories. I want to do this:
#::-- Direct STDOUT and STDERROR to repositories --::#
exec 2>"${_ERRORFILE}" > "${_LOGFILE}"
exec 2>"/new/path/file.err" >... (7 Replies)
I have an existing shell script that I am trying to modify. I have about 10 lines of info I want to overwrite using text someone emailed to me. I guess what I am trying to do basically is like a copy/paste, but it's not working for me.
I am using Cygwin and vi editor.
I open the script and... (4 Replies)
Hi
script> isumid 98765432
if i give above command in cmd prompt it is running the same thing if i give inside the shell script it is not working
below is the code
#!/bin/bash
isumid 98765432
please give me a solution (16 Replies)
I am trying to learn to write basic shell scripts. I have a little experience with perl but none with shell. I am trying to write a simple script to write the last 15 or so lines of log files for my web server to a temp file so I can view all at once. Here's what I have. Are you not able to use... (6 Replies)
Can anyone help me out in visualizing on what is the logic behind simple unix commands. For Eg: ls command lists files and directories, how it displays I need to know the source code for commands like this. (1 Reply)
Hi friends this is first post i am very new to shell scripting so i require your expertise to do the following thank u
I need to write a shell script which will run the following commands
pg_dump bank > backup(Enter)
Wait for bash prompt to appear coz it indicates that the command is... (23 Replies)
I would be thankful if anyone could show me commands to do the following tasks in vi:1) How can I undo or redo my last action in vi editor.
2) How can I copy only a word or a portion of line (not the whole line) in vi, like
we can select text and press ctrl+c in notepad to copy any text.
3)... (4 Replies)
Hi ,
I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell.
So scenario is that
- I need to have one shell script which is ran as a part of crontab
- in this shell script I need to do a... (2 Replies)