-
grep the tnsnames.ora
Dear all,
I have a unix command - grep to embed into my shell script program to find the service name in tnsnames.ora
For example,
mydb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL= TCP)(Host= myhost)(Port= 1521))
(CONNECT_DATA = (SID = testdb))
)
mydb2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL= TCP)(Host= myhost2)(Port= 1521))
(CONNECT_DATA = (SID = testdb2))
)
how to grep the value mydb and mydb2 out and assign to a file ?
Thanks
-
Do a "man grep" at your UNIX prompt.
You can do grep "some string" file_name > search.file
-
Hi,
If you know the exact number of rows(e.g. 4) following mydb string in your tnsnames.ora file(s) you can write:
grep -A4 -h -E "mydb.*=" tnsnames.ora > file.out
-A4 = + 4 rows after the hit
-h = no header
-E = extended regular expression
It works in GNU grep.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|