search in shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search in shell
# 1  
Old 02-27-2008
search in shell

The script should check the entire create table definition upto ; and list out the test suite names which does not primary index in the definition.

Example:
main directory which has subdirectries also:

/home/surya

File name : abc.text

create table data (pi int, col1 char(1), col2 char(5), col3 int)
primary index (pi);

1.Check for Create table upto ;
2.omit primary index if found and display the file names and the directory it was found

Thanks,
surya

Last edited by a.suryakumar; 02-27-2008 at 06:57 AM..
# 2  
Old 02-27-2008
grep 'em

Why don't you just try grep?

If the problem is still complex, be specific with your requirement.
# 3  
Old 02-27-2008
i have tried with grep like this didn't help my requirement
Requirement:

check for the table definition which does not have "primary index" as in example in the whole directories which has subdirectories also.

create table will be addressed as CT or CREATE TABLE or ct or create table

create table data (pi int, col1 char(1), col2 char(5), col3 int)
primary index (pi);


it should list whole create table whole definition upto ; even if it is next lines of the file,

display the definition along with the directory and filename
# 4  
Old 02-27-2008
HI,

Why dont you use the grep -v option?, the grep -v option will ignore the "primary index" in your case.
# 5  
Old 02-27-2008
i want create table definition also:

List out the file names which has “create table upto ; “ even if it's in next line.
List out directory found and the file name which satisfied the above criteria:

Example:

Ab.text:

create table data (pi int, col1 char(1), col2 char(5), col3 int) primary index (
pi)




;
# 6  
Old 02-27-2008
Hi,

For example you are in the home directory and searching for the files which consists of the text "create..." , irrelevent to the location of files (even if it is in child directory),

grep -R "create"|grep -v "unique index"

Use the above command from the parent directory,
this will list the files which contains the text "create" from current + child directories. Then in the o/p ignore the files which contains the text "unique index".

grep -R ---> recrusive grep (searches the string in the child directries too)
grep-v ----> Ignores the given string from the o/p.
# 7  
Old 02-27-2008
actually it has to search the whole create table definition if found

starting from CREATE TABLE ....... to ;

Example:

if the contains :

CREATE TABLE Table1, FALLBACK
(col1 CHAR(4),
col2 INTEGER,
col3 INTEGER,
col4 INTEGER,
col5 INTEGER,
col6 INTEGER)
UNIQUE PRIMARY INDEX (col2)
;

CREATE INDEX (col3) ON Table1 ;

INS Table1 VALUES ( 'AAA',1,1,1,1,1 ) ;
INS Table1 VALUES ( 'BBB',2,2,2,2,2 ) ;
INS Table1 VALUES ( 'CCC',3,3,3,3,3 ) ;
INS Table1 VALUES ( 'DDD',4,4,4,4,4 ) ;

CREATE VIEW View1 as SELECT * from Table1 ;

the search command should return :


CREATE TABLE Table1, FALLBACK
(col1 CHAR(4),
col2 INTEGER,
col3 INTEGER,
col4 INTEGER,
col5 INTEGER,
col6 INTEGER)
UNIQUE PRIMARY INDEX (col2)
;
i think grep will search only single,the search has to traverse the entire definition upto ; and display ...

sorry for the trouble.....,will be glad if you help me
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search shell

good afternoon friends how can I find a shell in all server paths I have only the name of the shell (2 Replies)
Discussion started by: tricampeon81
2 Replies

2. Shell Programming and Scripting

Search and replace in shell scripting

I am trying to write shell script to find and replace using Sed. but i am unable to complete the setting. need help in doing that. Requirement: FROM "${O_INSTANCE}/diag/logs/${C_TYPE}/${C_NAME}/httpd.pid" TO "/var/opt/<SID>_<HOSTNAME>/Apache/httpd.pid" (10 Replies)
Discussion started by: avmk0407
10 Replies

3. Shell Programming and Scripting

UNIX Shell Script Help for pattern search

Hi Need help for below coding scenario. I have a file with say 4 lines as below. DEFINE JOB TPT_LOAD_INTO_EMP_DET ( TDPID = @TPT_TDSERVER , USERNAME = @TPT_TDUSER ) ; ( 'DROP TABLE '||@TPT_WRKDB ||'.LOG_'||@TPT_TGT ||' ; ') , SELECT * FROM OPERATOR (FILE_READER) ; ) ; Now I want to... (5 Replies)
Discussion started by: Santanu2015
5 Replies

4. Shell Programming and Scripting

Search and replace in shell

I have a server.xml in about 50 instances of JBOSS servers which has the following line <Engine defaultHost="localhost" name="jboss.web"> I need to append something into this line based on the hostname . For example hostname abcdprod40j.corp.abc.net <Engine defaultHost="localhost"... (1 Reply)
Discussion started by: gubbu
1 Replies

5. Shell Programming and Scripting

Search only the first occurence in shell

Hello I have a configuration file and I want to extract a part of this configuration. Example of configuration: profile toto { bla bla blabla } conftest { toto { myarguements } I try to do a sed command: sed -n '/'toto' {$/,/^}/p' But the result is : profile toto { (6 Replies)
Discussion started by: maverick31
6 Replies

6. UNIX for Dummies Questions & Answers

Shell script for search and replace by field

Hi, I have an input file with below data and rules file to apply search and replace by each field in the input based on exact value or pattern. Could you please help me with unix script to read input file and rules file and then create the output and reject files based on the rules file. Input... (13 Replies)
Discussion started by: chandrath
13 Replies

7. Shell Programming and Scripting

Shell script to search a keyword in six different servers

Hello, I need a shell script which takes search keyword as input and then searches logs in six different servers and provide me the logs where in it found the keyword. Can anyone help???? (1 Reply)
Discussion started by: tomlui2010
1 Replies

8. Shell Programming and Scripting

Search the shell variable inside awk

Hai, I need to search a variable inside a file using awk in AIX. for ex: file.txt one two three four five i need to get the lines with two awk '/two/ {print}' file.txt But i need to change the two as a variable since it would be changed on runtime..i tried like below..nothing give... (3 Replies)
Discussion started by: jesu
3 Replies

9. Shell Programming and Scripting

Help With Constructing A Korn Shell Search Loop

Hello All, I am a statistician and I am very new to the world of ksh programming. Daily, I analyze millions of rows of data and land information to DB2 tables. I have recently been asked to develop a ksh script to FTP an export file containing line item data from the production environment to the... (2 Replies)
Discussion started by: jonesdk5
2 Replies

10. Shell Programming and Scripting

how to search xml tags using unix shell

Hi All, Good day Here is my data: <Journal> <JournalCode>2</JournalCode> <JournalType>L</JournalType> <JournalEntry>SG</JournalEntry> <JournalAmount>-0.05</JournalAmount> </Journal> Problem: 1) I need to query the above tags in xml. Which is from the header <Journal>... (4 Replies)
Discussion started by: lutinoman
4 Replies
Login or Register to Ask a Question