Sponsored Content
Top Forums Shell Programming and Scripting to extract string from main string and string comparison Post 302573874 by vivek d r on Wednesday 16th of November 2011 01:34:52 AM
Old 11-16-2011
Question to extract string from main string and string comparison

continuing from my previous post, whose link is given below as a reference
HTML Code:
https://www.unix.com/shell-programming-scripting/171076-shell-scripting.html#post302573569


consider there is create table commands in a file for eg:

Code:
CREATE TABLE `Blahblahblah` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`action` enum('Change','Delete','Add','Locked','Unlocked') COLLATE utf8_unicode_ci DEFAULT 'Change',
`date` datetime DEFAULT NULL,

`reserved1` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`reserved2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`zoneId` int(11) DEFAULT NULL,
) ENGINE=InnoDB AUTO_INCREMENT=2000 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

like the above block there are many blocks in the file, i mean many create table queries in the file.
i have two doubts which i need help in
1) what i need to do is separate out one create table block based on idetifier such as "create table" which is the start and "ENGINE=" as end and seperate it out and write to a file for processing (which i will be doing in a while loop so that every time a new create table overwrite in that particular file for processing).
2) if i have a string "CREATE TABLE `Blahblahblah`" in a variable how to extract `blahblahblah` and store it in a variable..?

help on these is deeply appreciated
thanks Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract a sub string from a main string

i need a shell program to extract a substring from a main string.. for eg:- main string is madhu.. sub string is mad o/p:- be mad. try to solve this one (5 Replies)
Discussion started by: madhu.it
5 Replies

2. Shell Programming and Scripting

extract a string from main string

i need a shell program,to extract a string from a main string. main string is "madhu" sub string is "mad"..means any word from the main string please di this (1 Reply)
Discussion started by: madhu.it
1 Replies

3. Shell Programming and Scripting

Search for string in a file and extract another string to a variable

Hi, guys. I have one question: I need to search for a string in a file, and then extract another string from the file and assign it to a variable. For example: the contents of the file (group) is below: ... ftp:x:23: mail:x:34 ... testing:x:2001 sales:x:2002 development:x:2003 ...... (6 Replies)
Discussion started by: daikeyang
6 Replies

4. Homework & Coursework Questions

passing letters from an array into a string for string comparison

attempting the hangman program. This was an optional assignment from the professor. I have completed the logical coding, debugging now. ##I have an array $wordString that initializes to a string of dashes ##reflecting the number of letters in $theWord ##every time the user enters a (valid)... (5 Replies)
Discussion started by: lotsofideas
5 Replies

5. Shell Programming and Scripting

Extract a string between 2 ref string from a file

Hi, May i ask if someone share some command for extracting a string between 2 ref string in a txt file My objective: i had a file with multiple lines and wants only to extract the string "watch?v=IbkAXOmEHpY" or "watch?v=<11 random character>", when i used "grep 'watch?=*' i got a results per... (4 Replies)
Discussion started by: jao_madn
4 Replies

6. Shell Programming and Scripting

Grep exact string from main string

Hi , am getting output file, it sontains the below values. ./hawk_DOM1_FIRST_ENV ./hawk_DOM2_SECOND_ENV ./hawk_DOM3_THIRD_ENV Now I need to grep the word "DOM1_FIRST_ENV","DOM2_SECOND_ENV" like that. I tired with cut -d "_". Its not working with any deleimiter. Can you please help to... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

7. Shell Programming and Scripting

Search String and extract few lines under the searched string

Need Assistance in shell programming... I have a huge file which has multiple stations and i wanted to search particular station and extract few lines from it and the rest is not needed Bold letters are the stations . The whole file has multiple stations . Below example i wanted to search... (4 Replies)
Discussion started by: ajayram_arya
4 Replies

8. Shell Programming and Scripting

To Search for a string and to extract the string from the text

Hi Team I have an huge xml where i need to search for a ceratin numbers. For example 2014-05-06 15:15:41,498 INFO WebContainer : 10 CommonServicesLogs - CleansingTriggerService.invokeCleansingService Entered PUBSUB NOTIFY MESSAGE () - <?xml version="1.0" encoding="UTF-8"... (5 Replies)
Discussion started by: Kannannair
5 Replies

9. Shell Programming and Scripting

How to extract every repeated string between two specific string?

Hello guys, I have problem with hpux shell script. I have one big text file that contains like SOH bla bla bla bla bla bla ETX SOH bla bla bla ETX SOH bla bla bla ETX What I need to do is save first SOH*BLA into file1.txt, save second SOH*BLA into file2.txt and so on.... (17 Replies)
Discussion started by: sembii
17 Replies

10. Shell Programming and Scripting

awk string comparison unterminated quoted string andrule of thumb

I have the logic below to look up for matches within the columns between the two files with awk. In the if statement is where the string comparison is attempted with == The issue seems to be with the operands, as 1. when " '${SECTOR}' " -- double quote followed by single quote -- awk matches... (1 Reply)
Discussion started by: deadyetagain
1 Replies
CREATE 
DOMAIN(7) SQL Commands CREATE DOMAIN(7) NAME
CREATE DOMAIN - define a new domain SYNOPSIS
CREATE DOMAIN domainname [AS] data_type [ DEFAULT default_expr ] [ constraint [, ... ] ] where constraint is: [ CONSTRAINT constraint_name ] { NOT NULL | NULL } PARAMETERS domainname The name (optionally schema-qualified) of a domain to be created. data_type The underlying data type of the domain. This may include array specifiers. Refer to the User's Guide for further information about data types and arrays. DEFAULT The DEFAULT clause specifies a default value for columns of the domain data type. The value is any variable-free expression (but subselects are not allowed). The data type of the default expression must match the data type of the domain. The default expression will be used in any insert operation that does not specify a value for the column. If there is no default for a domain, then the default is NULL. Note: If a default value is specified for a particular column, it overrides any default associated with the domain. In turn, the domain default overrides any default value associated with the underlying data type. CONSTRAINT constraint_name An optional name for a constraint. If not specified, the system generates a name. NOT NULL Values of this domain are not allowed to be NULL. NULL Values of this domain are allowed to be NULL. This is the default. This clause is only available for compatibility with non-standard SQL databases. Its use is discouraged in new applications. OUTPUTS CREATE DOMAIN Message returned if the domain is successfully created. DESCRIPTION
CREATE DOMAIN allows the user to register a new data domain with PostgreSQL for use in the current data base. The user who defines a domain becomes its owner. If a schema name is given (for example, CREATE DOMAIN myschema.mydomain ...) then the domain is created in the specified schema. Otherwise it is created in the current schema (the one at the front of the search path; see CURRENT_SCHEMA()). The domain name must be unique among the types and domains existing in its schema. Domains are useful for abstracting common fields between tables into a single location for maintenance. An email address column may be used in several tables, all with the same properties. Define a domain and use that rather than setting up each table's constraints individually. EXAMPLES
This example creates the country_code data type and then uses the type in a table definition: CREATE DOMAIN country_code char(2) NOT NULL; CREATE TABLE countrylist (id INT4, country country_code); COMPATIBILITY
SQL99 defines CREATE DOMAIN, but says that the only allowed constraint type is CHECK constraints. CHECK constraints for domains are not yet supported by PostgreSQL. SEE ALSO
DROP DOMAIN [drop_domain(7)], PostgreSQL Programmer's Guide SQL - Language Statements 2002-11-22 CREATE DOMAIN(7)
All times are GMT -4. The time now is 07:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy