Sponsored Content
Full Discussion: Using gawk to clean up SQL
Top Forums Shell Programming and Scripting Using gawk to clean up SQL Post 302273920 by ripat on Tuesday 6th of January 2009 07:22:46 AM
Old 01-06-2009
Using gawk to clean up SQL

Hi,

What would be the best awk commands to change this:
Code:
CREATE TABLE "allow_ip_services" (
  "host" varchar(20) default NULL,
  "user" varchar(30) NOT NULL,
  "services" varchar(100) default NULL,
  KEY "host" ("host"),
  KEY "user" ("user")
);

into this

Code:
CREATE TABLE "allow_ip_services" (
  "host" varchar(20) default NULL,
  "user" varchar(30) NOT NULL,
  "services" varchar(100) default NULL
);

If I do a simple gawk '!/KEY/' file I end up with:
Code:
CREATE TABLE "allow_ip_services" (
  "host" varchar(20) default NULL,
  "user" varchar(30) NOT NULL,
  "services" varchar(100) default NULL,
);

My SQLite doesn't like the trailing coma :=)
 

9 More Discussions You Might Find Interesting

1. AIX

Directory clean up

I want to write a script in ksh that will delete file that are more than 2 weeks old. (4 Replies)
Discussion started by: jango
4 Replies

2. UNIX for Advanced & Expert Users

Clean an LV out of the ODM

I recently had a disk crash and was not able to clean the dump lv off the disk. Now trying to create new lvdump I am running into errors. My question is how do I remove the old lv out of the ODM? I have tried going through smit and also just rmlv and it cannot find the lv. Yet when I run lslv on... (0 Replies)
Discussion started by: Wamland
0 Replies

3. Shell Programming and Scripting

clean up script

I have a script which would monitor a given directory and delete any files which are older than 10 days. I was going to set the 10 crob jobs to perform this operation for 10 different directories (some are actually sub-directories), but my boss doesn't like that idea, so I need to do that in one... (1 Reply)
Discussion started by: mpang_
1 Replies

4. UNIX for Advanced & Expert Users

Clean File

BeginDate 07/01/06 End: 07/31/06 Cust: A02991 - Burnham 0002000 5,829,773 145.3 0009701 4,043,850 267.3 2005000 286,785.13 100.0 BeginDate 07/01/06 End: 07/31/06 Cust: A01239 - East Track PSE Index A 0009902 317,356.82 890.2 0020021 ... (5 Replies)
Discussion started by: kris01752
5 Replies

5. Shell Programming and Scripting

clean /etc/hosts

hi all, i need to write a script. it should be able to clean the /etc/hosts file like this: first field is the ip (what else ;)) second field is the fqdn (full qualified domain name) third field is the hostname the fourth to n'th field is the rest. i hope you understand what is needed?... (5 Replies)
Discussion started by: DukeNuke2
5 Replies

6. UNIX for Dummies Questions & Answers

Help me clean this up

UNIX amature/novice. I've written a script (it works) that needs to be cleaned up. I'm searching for a way to perform a "go to , perform this then return" section of code. The books I have and searches i"ve done so far do not show me how to do this. I've pasted in the current code below. I've... (1 Reply)
Discussion started by: scanner248
1 Replies

7. AIX

How to clean PV id?

When I run command: >chdev -l hdisk1 -a pv=clear It shows Method error (/etc/methods/chgdisk): 0514-062 Cannot perform the requested function because the specified device is busy. run: #>fuser -kxuc /dev/raw1 /dev/raw1: How to clean PV id? (4 Replies)
Discussion started by: rainbow_bean
4 Replies

8. Shell Programming and Scripting

How to clean this script?

Hello guys, this script partially works but it's still pretty ugly and, moreover, if the month is jan/feb/mar... it doesn't work at all. Could anyone say me how to correct, cut and clean a little bit? #!/usr/bin/ksh egrep -v -e "^\s*#" /file/permission | awk '{ print $1 }' | sort | uniq... (3 Replies)
Discussion started by: gogol_bordello
3 Replies

9. Shell Programming and Scripting

Clean up the space

Hi I just want to clean up the space in UNIX. Is there any special command that does this process or do I need to manually type the following rm <filename> Any help would be really appreciated. Thanks (2 Replies)
Discussion started by: bobby1015
2 Replies
Mail::SpamAssassin::SQLBasedAddrList(3) 		User Contributed Perl Documentation		   Mail::SpamAssassin::SQLBasedAddrList(3)

NAME
Mail::SpamAssassin::SQLBasedAddrList - SpamAssassin SQL Based Auto Whitelist SYNOPSIS
my $factory = Mail::SpamAssassin::SQLBasedAddrList->new() $spamtest->set_persistent_addr_list_factory ($factory); ... call into SpamAssassin classes... SpamAssassin will call: my $addrlist = $factory->new_checker($spamtest); $entry = $addrlist->get_addr_entry ($addr, $origip); ... DESCRIPTION
A SQL based persistent address list implementation. See "Mail::SpamAssassin::PersistentAddrList" for more information. Uses DBI::DBD module access to your favorite database (tested with MySQL, SQLite and PostgreSQL) to store user auto-whitelists. The default table structure looks like this: CREATE TABLE awl ( username varchar(100) NOT NULL default '', email varchar(255) NOT NULL default '', ip varchar(16) NOT NULL default '', count int(11) NOT NULL default '0', totscore float NOT NULL default '0', signedby varchar(255) NOT NULL default '', PRIMARY KEY (username,email,signedby,ip) ) TYPE=MyISAM; Your table definition may change depending on which database driver you choose. There is a config option to override the table name. This module introduces several new config variables: user_awl_dsn user_awl_sql_username user_awl_sql_password user_awl_sql_table user_awl_sql_override_username see "Mail::SpamAssassin::Conf" for more information. new public class (Mail::SpamAssassin::SQLBasedAddrList) new () Description: This method creates a new instance of the SQLBasedAddrList factory and calls the parent's (PersistentAddrList) new method. new_checker public instance (Mail::SpamAssassin::SQLBasedAddrList) new_checker (\% $main) Description: This method is called to setup a new checker interface and return a blessed copy of itself. Here is where we setup the SQL database connection based on the config values. get_addr_entry public instance (\%) get_addr_entry (String $addr, String $signedby) Description: This method takes a given $addr and splits it between the email address component and the ip component and performs a lookup in the database. If nothing is found in the database then a blank entry hash is created and returned, otherwise an entry containing the found information is returned. If a with_awl_signer configuration option is enabled only addresses signed by the given signing identity are taken into account, or, if $signedby is undefined (or empty) only unsigned entries are considered. A key, "exists_p", is set to 1 if an entry already exists in the database, otherwise it is set to 0. add_score public instance (\%) add_score (\% $entry, Integer $score) Description: This method adds a given $score to a given $entry. If the entry was marked as not existing in the database then an entry will be inserted, otherwise a simple update will be performed. NOTE: This code uses a self referential SQL call (ie set foo = foo + 1) which is supported by most modern database backends, but not everything calling itself a SQL database. remove_entry public instance () remove_entry (\% $entry) Description: This method removes a given $entry from the database. If the ip portion of the entry address is equal to "none" then remove any perl-IP entries for this address as well. finish public instance () finish () Description: This method provides the necessary cleanup for the address list. _unpack_addr private instance (String, String) _unpack_addr(string $addr) Description: This method splits an autowhitelist address into it's two components, email and ip address. perl v5.16.3 2011-06-06 Mail::SpamAssassin::SQLBasedAddrList(3)
All times are GMT -4. The time now is 01:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy