Possible to insert a few lines of code into a file at a specific point?
Hi Folks -
How would I go about inserting a chunk of lines (3) into a specific portion of a file?
The background is I have a script (non shell) that it executed daily, however on Sundays, I uncomment a section of code so that piece can be run as well.
So I was hoping to write a piece of code to insert the 3 lines into this particular file every Sunday, and remove when complete.
Is this possible?
The lines are as follows:
Can I put two commented out identifiers in the script that says place code between these? and then delete lines between these when finished?
My shell script is is what will drive the automation, but the actual file that gets executed is an .mxl file which is read by the application that it's getting executed against.
My shell script is is what will drive the automation, but the actual file that gets executed is an .mxl file which is read by the application that it's getting executed against.
Its an oracle product (Essbase).
For example, my shell script would contain:
Can the Essbase application read AC.mxl (or should that be AC.xml) from standard input or does it have to be given the pathname of the file containing the script as an operand?
Does the scripting language read by Essbase have a comment statement? If so what is its format?
What operating system are you using?
What shell are you using?
This User Gave Thanks to Don Cragun For This Post:
Essbase reads ".mxl" (not .xml) and it's passed to the Essbase application using the startMaxl.sh utility and corresponding path and file name of the maxl (as shown above).
A comment is created by the following:
For this task, I am coding on an AIX environment using .ksh.
I was thinking something like this:
Where my .mxl would have the following comments:
This is untested as I need to step out for a bit, but thats what i'm thinking.
I would tend to leave the code in the file where it will be executed, but have it commented out on the days when it shouldn't run...
Have your script look for the strings (Start|End) Sunday Only and if it isn't Sunday, remove the comment terminator and start characters shown in red. If it is Sunday, insert the characters shown in red if they aren't already there. That way, anyone looking at the file will know what it will be doing any day of the week without having to know about a magic editing session that adds invisible code one day of the week.
This User Gave Thanks to Don Cragun For This Post:
I appreciate that I'm coming to this thread very late but, having read it a few times, isn't there a better way than dynamically editing a script (or whatever you want to call it)?
If the 3 lines are always the same code (ie, they don't contain moving date information or anything like that) why can't you have two copies (different files) of the script, one for weekdays and one for Sundays? Then test for day of week at start of script and run the weekday or Sunday script as appropriate. Even if the file has to be a certain name you could rename files before execution on a Sunday and rename them back on completion.
Dear all,
i am having text file like below
surya
rama
ranga
laxman
rajesh
reddy
i want add string (OK) before a text from line 3 to 5
the result will be
surya
rama
OK ranga
OK laxman
OK rajesh
reddy (1 Reply)
Hi,
Anyone can help me in Solaris command on how to insert a file at specific line.
I want file1.sql content to be inserted on file2.sh after "recover database using backup controlfile until cancel".
# file1.sql
/archivelogs/927_822338133.arc
/archivelogs/671_822338107.arc... (3 Replies)
This could be a really dummy question.
I have a log text file.
What unix command to extract line from specific string to another specific string.
Is it something similar to?:
more +/"string" file_name
Thanks (4 Replies)
Hi I'm a beginner, and i've been having trouble joining two lines.
I need to convert this file
1097ALABAMA Mobile County METHOMYL INSE
CTICIDES 6 1.6200000E+00 1.8000001E+00
1003ALABAMA Baldwin County ... (5 Replies)
this is Korn shell unix.
The scenario is I have a pipe delimited text file which needs to be customized. say for example,I have a pipe delimited text file with 15 columns(| delimited) and 200 rows. currently the 11th and 12th column has null values for all the records(there are other null columns... (4 Replies)
So I work in a 1 to 1 laptop deployment and sometimes we need to mass order parts. The vendor will send us a text file and we have to manually input serial numbers. Well I have a full blown web based inventory system which I can pull serial number reports from.
I then have to input the part... (4 Replies)
Hi,
I need to add Pipe (|) at 5th and 18th position of all records a file. How can I do this?
I tried to add it at 5th position using the below code. It didnt work. Please help!!!
awk '{substr($0,5,1) ~ /|/}{print}' $input_file > $temp_file (1 Reply)
Hi,
I am new to ksh scripting and I have a problem.
I have a file in which I have to search for a particular pattern say 'a' then from that line I need to search for another pattern say 'b' in the previous lines and thne print the file from pattern 'b' till the end of file.
For eg:
... (2 Replies)
Hi,
I need to insert two new lines in a file:
The file:
".....
......
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
....
....
"
I need to add the lines:
LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$APACHE_HOME/modules'
DOWNLOADMODULE_CONF_PATHNAME='$APACHE_HOME/conf/DWLModule.cfg'
right... (2 Replies)
Hi There
I have this file that I would like to add entries to, however, there is a "}" as the last line that I need to keep. Basically i would like to know how I can write a script that will add new lines at the second to last line position (ie always add new line above the close bracket)
... (17 Replies)