Sponsored Content
Top Forums Shell Programming and Scripting to extract string from main string and string comparison Post 302573926 by vivek d r on Wednesday 16th of November 2011 07:17:44 AM
Old 11-16-2011
my goal is to write a shell script which takes two mysql dump files(one is latest dump which has new changes to be made and other one is older mysql dump) the script compares both the files and and give the delta (that is changed to to be made ) as output. the changes in the sense.. new mysql dump file has two more columns added in the table blahblahblah so the scipt finds out which are the columns missing and from which table and writes alter table query to that particular table. i am stuck in the part where i need to extract table wise from the file and also in comparison between files. right now i have wrote shell script which just prints out lines missing from one file compared to other.. its copy is shown in
HTML Code:
https://www.unix.com/shell-programming-scripting/171076-shell-scripting.html#post302573569

thanks for replying in short time

---------- Post updated at 03:45 PM ---------- Previous update was at 03:41 PM ----------

this is required for my project since currently we use mysql testbench to get this delta changes of database compared to new changes. and use this delta changes file to alter the old database so that it reflects all the new changes. but i want to avoid using testbench for this function and write a shell script which performs its functions.

---------- Post updated at 05:47 PM ---------- Previous update was at 03:45 PM ----------

Quote:
Originally Posted by ahamed101
Whatever you have mentioned can be done, but what is your ultimate goal?...

Code:
table_name=$( awk -F\` '/CREATE TABLE/{print $2}' input_file )

--ahamed
the above query works good thanks.. :-)
consider the below code

Code:
`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,

these are the column names in the earlier mentioned table. how to extract these column names dynamically cause i want to use it in a function so if i send either
`reserved2` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
or
`zoneId` int(11) DEFAULT NULL
(the above two line will be stored in the variable.. i am using while loop to read from file so technically in first run one column will be held in $line )
it should extract reserved2 or zoneid respectively.. how to do it..?
 

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
mysqmail-dovecot-logger(8)				      System Manager's Manual					mysqmail-dovecot-logger(8)

NAME
mysqmail-dovecot-logger - logs dovecot-imapd and dovecot-pop3d traffic to a mysql database SYNOPSIS
mysqmail-dovecot-logger subprogram [ args ... ] DESCRIPTION
mysqmail-dovecot-logger reads the syslog using tail -F, and for each dovecot lines of POP3 and IMAP corresponding to a disconnection, mysq- mail-dovecot-logger writes the total used bandwidth corresponding to the username. Configuration is read from /etc/mysqmail.conf. mysqmail-dovecot-logger uses a table corresponding to this one: CREATE TABLE IF NOT EXISTS pop_access ( id varchar(32) NOT NULL default '', uid int(11) NOT NULL default '65534', gid int(11) NOT NULL default '65534', home varchar(255) NOT NULL default '', shell varchar(255) NOT NULL default '', mbox_host varchar(120) NOT NULL default '', crypt varchar(50) NOT NULL default '', passwd varchar(50) NOT NULL default '', active int(11) NOT NULL default '1', start_date date NOT NULL default '0000-00-00', expire_date date NOT NULL default '0000-00-00', quota_size int(11) NOT NULL default '0', type varchar(20) NOT NULL default 'default', memo text,du bigint(20) NOT NULL default '0', another_perso varchar(5) NOT NULL default 'no', redirect1 varchar(255) default NULL, redirect2 varchar(255) default NULL, localdeliver varchar(10) NOT NULL default 'yes', pop3_login_count int(9) NOT NULL default '0', pop3_transfered_bytes int(14) NOT NULL default '0', imap_login_count int(9) NOT NULL default '0', imap_transfered_bytes int(14) NOT NULL default '0', last_login int(14) NOT NULL default '0', PRIMARY KEY (id,mbox_host) ) TYPE=MyISAM VERSION
This documentation describes mysqmail-dovecot-logger version 0.4.4 or superior. See http://gplhost.com/softwares-mysqmail.html for updates. SEE ALSO
qmail-send(3), syslog(3), logger(8) mysqmail-dovecot-logger(8)
All times are GMT -4. The time now is 06:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy