11-26-2007
Apologies for the confusion in the original problem statement. I should have given more detail.
The file I am processing contains SQL statements (It's from an Oracle database export).
For each table these is a block of statements (each statement ends with ';') like -
create table tablename ....
....
.... 65536 ....
.... ;
alter table tablename
............ ;
alter table tablename
.... 65536 .... ;
alter table tablename
.... 65536 .... ;
alter table tablename
............ ;
<next create statement>
For each table there will only be one 'create' statement, but any number of 'alter' statements.
Each 'alter' statement (and the 'create' statement) has a variable number of lines.
The 'alter' statements may or may not (I missed this on the original problem definition) have the '65536'.
I am trying to change the '65536' to a variable value (using a unix variable) which comes from a parameter file. The value will be something like '524288', but only for the 'alter' statements.
So the resulting file would be like -
create table tablename ....
....
.... 65536 ....
.... ;
alter table tablename
............ ;
alter table tablename
.... 524288 .... ;
alter table tablename
.... 524288 .... ;
alter table tablename
............ ;
<next create statement>
The awk code works fine until it hits the first 'alter' with no '65536' in it, when it changes the '65536' of the next occurrence, which may be in the 'create' statement.
Your efforts are much appreciated.
Regards
Bob
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi
I have the following file that i need to run a sed command on
1<tab>running
2<tab>running
3<tab>running
4<tab>running
I want to be able to replace a line i.e the second one with '2<tab>failed'. As the first number is unique that can be used to search for the relevant line (using ^2 i... (5 Replies)
Discussion started by: handak9
5 Replies
2. Shell Programming and Scripting
Hi
Can anyone provide me the replacement of sed with xargs perl syntax for the below
sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//'
This should be without looping has to take minimal time for search (0 Replies)
Discussion started by: dbsurf
0 Replies
3. Shell Programming and Scripting
sed -i 's:"ps -ef | grep $(cat $PID_FILE) | grep -v grep":"ps -C java -o pid,cmd | grep ${SERVER_NAME} | cut -d' ' -f1 | grep -v grep":g' scriptName
That's what I'm attempting to do. I'm attempting to replace this:
ps -ef | grep $(cat $PID_FILE) | grep -v grep
with this:
ps -C java -o... (5 Replies)
Discussion started by: cbo0485
5 Replies
4. Shell Programming and Scripting
This seems like it should be an easy problem, but I'm a noob and I can't figure it out. I'm trying to use sed, but would be happy to use anything that does the job.
I am trying to trim off a fixed number of unknown characters from 2 different : delimited fields while keeping the intervening... (4 Replies)
Discussion started by: helix_w
4 Replies
5. Shell Programming and Scripting
I am trying to replace the line which has string "tablespace" not case senstive....
with below simple script: mysrcipt.sh
sed "s/.*/TABLESPACE USERS/g" create_table > tmp
mv tmp create_table
Is there any better way to do it? If Search string tooooooo long it will be tough to code in... (4 Replies)
Discussion started by: ganeshd
4 Replies
6. Shell Programming and Scripting
I have following requirement.
Say, my text file contains following patterns
{2010501005|XXGpvertex|9|0|17|0|{|{30100001|XXparameter_set|@@@@{{30001002|XXparameter|!prototype_path|$AB_COMPONENTS/Sort/Sort.mpc|3|2|Pf$|@{0|}}
}}@0|@315000|78500|335000|99000|114000|87000|17|And the Sort|Ab... (8 Replies)
Discussion started by: Shell_Learner
8 Replies
7. Shell Programming and Scripting
Hi,
i have a file with lines,
file.txt
-------
test is fun
testing is better
I need to replace 'test' to 'develop' and i used,
a=test
b=develop
sed "s,$a,$b,g" -------- but i see the word 'testing' is also replaced. Need some solution. Is there any way i could replace only 'test' ? (4 Replies)
Discussion started by: giri_luck
4 Replies
8. Shell Programming and Scripting
Hi
,"environment":"accent-release","build":"ac-1112_c_Alph_Nop-release_rele-1112_c_Alph_Nop-release_rele","tags":""
above is the config file, where in i want to replace value after build inside the double quotes... that value i'll be passing as parameter
for example if m passing
... (1 Reply)
Discussion started by: nikhil jain
1 Replies
9. UNIX for Dummies Questions & Answers
I need to make permanent changes in the file after find and replace using sed.
for this i am using sed -i
However this is not working. says
sed: illegal option -- i
I am working on Sun Solaris uname -a
SunOS aspsun14 5.10 Generic_150400-13 sun4u sparc SUNW,SPARC-Enterprise
any other work... (3 Replies)
Discussion started by: gotamp
3 Replies
10. Shell Programming and Scripting
Hello,
I'm using Bash and Sed to replace text within a text file (1.txt) twice in one script. Using a for loop I'm initially replacing any 'apple' words with the variable 'word1' ("leg). I'm then using another for loop to replace any 'apple' words with the variable 'word2' ("arm"). This task is... (2 Replies)
Discussion started by: Flip-Flop
2 Replies
LEARN ABOUT SUSE
nismatch
nismatch(1) User Commands nismatch(1)
NAME
nismatch, nisgrep - utilities for searching NIS+ tables
SYNOPSIS
nismatch [-AchMoPv] [-s sep] key tablename
nismatch [-AchMoPv] [-s sep] colname = key... tablename
nismatch [-AchMoPv] [-s sep] indexedname
nisgrep [-AchiMov] [-s sep] keypat tablename
nisgrep [-AchiMov] [-s sep] colname = keypat... tablename
DESCRIPTION
The utilities nismatch and nisgrep can be used to search NIS+ tables. The command nisgrep differs from the nismatch command in its ability
to accept regular expressions keypat for the search criteria rather than simple text matches.
Because nisgrep uses a callback function, it is not constrained to searching only those columns that are specifically made searchable at
the time of table creation. This makes it more flexible, but slower, than nismatch.
In nismatch, the server does the searching, whereas in nisgrep the server returns all the readable entries and then the client does the
pattern-matching.
In both commands, the parameter tablename is the NIS+ name of the table to be searched. If only one key or key pattern is specified with-
out the column name, then it is applied searching the first column. Specific named columns can be searched by using the colname=key syntax.
When multiple columns are searched, only entries that match in all columns are returned. This is the equivalent of a logical join opera-
tion.
nismatch accepts an additional form of search criteria, indexedname, which is a NIS+ indexed name of the form:
[ colname=value, ... ],tablename
OPTIONS
The following options are supported:
-A All data. Return the data within the table and all of the data in tables in the initial table's concatenation path.
-c Print only a count of the number of entries that matched the search criteria.
-h Display a header line before the matching entries that contains the names of the table's columns
-i Ignore upper/lower case distinction during comparisons.
-M Master server only. Send the lookup to the master server of the named data. This guarantees that the most up to date infor-
mation is seen at the possible expense that the master server may be busy.
-o Display the internal representation of the matching NIS+ object(s).
-P Follow concatenation path. Specify that the lookup should follow the concatenation path of a table if the initial search is
unsuccessful.
-s sep This option specifies the character to use to separate the table columns. If no character is specified, the default separa-
tor for the table is used.
-v Verbose. Do not suppress the output of binary data when displaying matching entries. Without this option binary data is
displayed as the string *BINARY*.
EXAMPLES
Example 1: Searching a table for a username
This example searches a table named passwd in the org_dir subdirectory of the zotz.com. domain. It returns the entry that has the user-
name of skippy. In this example, all the work is done on the server:
example% nismatch name=skippy passwd.org_dir.zotz.com.
Example 2: Finding users using specific shells
This example is similar to the one above, except that it uses nisgrep to find all users in the table named passwd that are using either
ksh(1) or csh(1):
example% nisgrep 'shell=[ck]sh' passwd.org_dir.zotz.com.
ENVIRONMENT VARIABLES
NIS_PATH If this variable is set, and the NIS+ table name is not fully qualified, each directory specified will be searched
until the table is found (see nisdefaults(1)).
EXIT STATUS
The following exit values are returned:
0 Successfully matches some entries.
1 Successfully searches the table and no matches are found.
2 An error condition occurs. An error message is also printed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWnisu |
+-----------------------------+-----------------------------+
SEE ALSO
niscat(1), nisdefaults(1), nisls(1), nistbladm(1), nis_objects(3NSL), attributes(5)
DIAGNOSTICS
No memory An attempt to allocate some memory for the search failed.
tablename is not a table The object with the name tablename was not a table object.
Can't compile regular expression The regular expression in keypat was malformed.
column not found: colname The column named colname does not exist in the table named tablename.
NOTES
NIS+ might not be supported in future releases of the SolarisTM Operating Environment. Tools to aid the migration from NIS+ to LDAP are
available in the Solaris 9 operating environment. For more information, visit http://www.sun.com/directory/nisplus/transition.html.
SunOS 5.10 10 Dec 2001 nismatch(1)