The RE searches require some quoting effort.
The index() function searches for plain strings and returns the position.
Also only the comments left from the search string matter.
Two reasons to go for the index() function rather than the RE.
Thanks for this, it makes the code much more usable since I can call it in a function instead of having to hard code the find line for each instance.
Quote:
Originally Posted by Chubler_XL
Surely there are better ways to do this than changing your source with awk. If this is a once off change have a programmer use an editor.
If it varies a lot why not have another define variable for NUMPAGES this can be passed as a compile time option using -D NUMPAGES=7 or something similar.
The number of shared memory pages could certainly be passed as a definition to the compiler since that part of the code is in c++. The script also determines a value for NUMPAGES by reading the src that generates the output and calculating the number of bytes to allocate. There are also several related PARAMETER values in old FORTRAN code that can't really be changed from the makefile since the f77 pre-processor is rather limited in that respect. It is possible to process FORTRAN src file with the C pre-processor (since I think that gnu compiles FORTRAN as C anyway). Doing that means that you can't use FORTRAN style includes in those files, so that messes up all of the other includes and defined parameters and such.
I need to run something to determine the size of the new output. There always seem to be issues in running a script from make and retrieving data if what you want is more than something simple. I could run something like
NUMPAGES=$(shell sizes.sh)
to get the number of pages, but that script determines several things that need to be modified in other sections of the code. I would either have to call the script many times, have many scripts, or write the data to a file, etc. It just seams easier to have the script make the changes since it needs to run anyway and the data is already in scope.
This is only an issue when the size of the output changes, so it doesn't come up as often as you might think. It is now automated by running make -f makefile resize all. The resize rule runs the script to determine the new sizes and makes the required changes in all the necessary sections of the code. The relevant objects and bin files are also deleted. The all rule then re-compiles and rebuilds the applications.
Is there a way to tell awk to ignore the first 11 lines of a file?? example, I have a csv file with all the heading information in the first lines. I want to split the file into 5-6 different files but I want to retain the the first 11 lines of the file.
As it is now I run this command:
... (8 Replies)
I want to replace this line : "test compare visible] true" and make it "#test compare visible] true".
How can I do it ? And it should be checked in many sub folder files also. (6 Replies)
Hello,
I have a file as follow
a
b
c
c
d
d
e
I would like to write a awk command to insert # from the first occurence of
"c" to the end of the files.
OUTPUT should be like this
a
b
#c (5 Replies)
My sql file xyz_abc.sql in this file there are multiple sql block in this block I need to find the following block
rem Subset Rows (&&tempName.*)
CREATE VIEW &&tempName.* AS
SELECT *
FROM &&tempName.*
WHERE f is not null
and replace with following code
rem Subset Rows... (9 Replies)
I am parsing a nagios config, searching for a string, and then printing the line 2 lines later (the "members" string). Here's the data:
define hostgroup{
hostgroup_name chat-dev
alias chat-dev
members thisisahostname
}
define hostgroup{
... (1 Reply)
hello everyone
my file contains many records, the following is a sample:
BEGIN
ASX1500000050002010120000000308450201012000177
ASX1100002000000201012000000038450201012000220
ASX1600100005000201012000000038450020101200177
ASX1900100006000201067000000058450020101200177... (2 Replies)
Find in first column and replace the line with Awk, and output new file
File1.txt"2011-11-02","Georgia","Atlanta","x","",""
"2011-11-03","California","Los Angeles","x","",""
"2011-11-04","Georgia","Atlanta","x","x","x"
"2011-11-05","Georgia","Atlanta","x","x","" ... (4 Replies)
My first comment on every file contains the license message. I want to replace with a new license message. I used the below sed script, which replaces all comments. What is the modification or any other method with awk script for the below to edit only the first comment(license message)?
#sed -f... (1 Reply)
I want to find common line in two files and replace the next line of first file with the next line of second file. (sed,awk,perl,bash any solution is welcomed ) Case Ignored. Multiple Occurrence of same line.
File 1:
hgacdavd
sndm,ACNMSDC
msgid "Rome"
msgstr ""
kgcksdcgfkdsb... (4 Replies)
How do you write a script to ignore all lines except the --- dash lines and then remove --- dashes from the data in a text file?
Also how do you separate data in a text file with a tab (for example, column1 (software) and column2 (date) ) ?
Here is my scripts : I am getting errors in... (3 Replies)