Sponsored Content
Full Discussion: Compare a paragraph
Top Forums Shell Programming and Scripting Compare a paragraph Post 302937810 by kenshinhimura on Monday 9th of March 2015 03:13:52 PM
Old 03-09-2015
Compare a paragraph

I know this is a challenging, its about comparing a 3 paragraph, from a whois command, i want to print what is the data that is not unique, example below is the admin phone and techphone, the rest is the same.it will print the correct and wrong

Code:
# whois google.com| sed -n '/Registry Registrant ID:/,/Tech Email:/p'| sed 's/Registry Tech ID:/\n\n&/'|sed 's/Registry Admin ID:/\n\n&/'

Desired Output:

Code:
THere is no difference between 3 paragraphs: And it will print the admin data
Admin Name: DNS Admin
Admin Organization: Google Inc.
Admin Street: 1600 Amphitheatre Parkway
Admin City: Mountain View
Admin State/Province: CA
Admin Postal Code: 94043
Admin Country: US
Admin Phone: +1.6506234000
Admin Phone Ext:
Admin Fax: +1.6506188571
Admin Fax Ext:
Admin Email: dns-admin@google.com


Output if wrong:
Code:
from google.com domain
Registry Registrant ID:
Registrant Phone: +1.6502530000

Registry Admin ID:
Admin Phone: +1.6506234000



Registry Tech ID:
Tech Phone: +1.6503300100

################################################
from yahoo.com domain

Registry Registrant ID:
Registrant Organization: yahoo.com

Registry Admin ID:
Admin Organization: yahoo1.com



These are the same data:
*****************************************************
domain from NBA.com

Registry Admin ID:
Admin Name: Information Technology
Admin Organization: NBA Basketball Association
Admin Street: 100 Plaza Drive 3rd Fl
Admin City: Secaucus
Admin State/Province: NJ
Admin Postal Code: 07094
Admin Country: US
Admin Phone: +001.201.9746996
Admin Phone Ext:
Admin Fax: +001.201.9746001
Admin Fax Ext:
Admin Email: internicadmin@nba.com



domain from Alibaba.com
Registry Admin ID:
Admin Name: Timothy Alexander Steinert
Admin Organization: Hangzhou Alibaba Advertising Co., Ltd.(杭州阿里巴巴广告有限公司)
Admin Street: No. 699 Wangshang Road , Binjiang District
Admin City: Hangzhou
Admin State/Province: Zhejiang
Admin Postal Code: 310052
Admin Country: CN
Admin Phone: +852.22155100
Admin Phone Ext:
Admin Fax: +852.22155200
Admin Fax Ext:
Admin Email: dnsadmin@hk.alibaba-inc.com

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bold the paragraph

Hi, I have a file with multiple paragraph. I want to look for some word and make that paragraph bold. How can I do that? Thanks, Karthik (3 Replies)
Discussion started by: caprikar
3 Replies

2. Shell Programming and Scripting

help, using awk to get paragraph

Hi, I'm trying to find pattern in log file. I'm using awk to search the pattern and print the paragraph. And it's not working well like I want. The file actually is TCAP message, it has format like this : ... ... ... ***************************************** INCOMING TCAP MESSAGE At... (6 Replies)
Discussion started by: kunimi
6 Replies

3. Linux

Extract a paragraph

Hi , Unix.com has been life saver for me I admit :) I am trying to extract a paragraph based on matching pattern "CREATE TABLE " from a ddl file . The paragraphs are seperated by blank line . Input file is #cat zip.20080604.sql1 CONNECT TO TST103 SET SESSION_USER OPSDM002 ... (2 Replies)
Discussion started by: capri_drm
2 Replies

4. UNIX for Dummies Questions & Answers

Split a paragraph

Hi, Consider the following paragraph. This is line1. This is line2, This is last line. I need the output as 4:This is last line. i.e The line after the blank line should be displayed along with line number. I am a unix begineer.Any one please help me to solve this problem (3 Replies)
Discussion started by: Sekar1
3 Replies

5. Shell Programming and Scripting

Pattern in a paragraph

Hi, I have read similar questions and I was not able to get a solution, so please help :) I have two files: 1-Pattern file contains list of patterns pattern1 pattern2 pattern3 pattern4 .... pattern# 2-input file in the format >hdhfshsdfjhpattern1xmbxmbxnmv... (4 Replies)
Discussion started by: tbakheet
4 Replies

6. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

7. Shell Programming and Scripting

Deletion of last Empty paragraph

Hello, I hava a file resulting from a script which ends as follows: 172|18|FOOTER|DISCLOSURE||16¶ 173|0|FOOTER|FILE||18¶ note the paragraph signs are only placed to demonstrate the problem I want it to return the same last lines but without the last empty paragraph i.e: ... (3 Replies)
Discussion started by: TasosARISFC
3 Replies

8. Shell Programming and Scripting

How to grep paragraph?

Hi, I have A file like this: >Contig1 AAAAAAATTTTTTCCCAATATATGAT ATATATAEATATATAT >Contig2 AAAAAAATTTTTTCCCAATATATGAT ATATATAEAATTTTTAATTTTTTCCCA ATCCCAAATATATAT >Contig3 AAAAAAATTTTTTCCCAATATATGAT ATATATAEAATTTTTAATTTTTTCCCA ATCCCAAATAAATTTTTTCCCAATAT ATGATATATATAEAATTTTTAATTTTT... (3 Replies)
Discussion started by: the_simpsons
3 Replies

9. UNIX for Dummies Questions & Answers

Extract paragraph that contains a value x<-30

I am using OSX. I have a multi-mol2 file (text file with coordinates and info for several molecules). An example of two molecules in the file is given below for molecule1 and molecule 2. The total file contains >50,000 molecules. I would like to extract out and write to another file only the... (2 Replies)
Discussion started by: Egy
2 Replies

10. Shell Programming and Scripting

How to extract a paragraph containing a given string?

Hello: Have a very annoying problem: Need to extract paragraphs with a specific string in them from a very large file with a repeating record separator. Example data: a file called test.out CREATE VIEW view1 AS something FROM table1 ,table2 as A, table3 (something FROM table4) FROM... (15 Replies)
Discussion started by: delphys
15 Replies
User::Simple::Admin(3pm)				User Contributed Perl Documentation				  User::Simple::Admin(3pm)

NAME
User::Simple::Admin - User::Simple user administration SYNOPSIS
$ua = User::Simple::Admin->new($db, $user_table); $ua = User::Simple::Admin->create_rdbms_db_structure($db, $user_table, [$extra_sql]); $ua = User::Simple::Admin->create_plain_db_structure($db, $user_table, [$extra_sql]); $ok = User::Simple::Admin->has_db_structure($db, $user_table); %users = $ua->dump_users; $id = $ua->id($login); $login = $ua->login($id); $otherattrib = $user->otherattrib($id); $ok = $usr->set_login($id, $login); $ok = $usr->set_passwd($id, $passwd); $ok = $usr->set_otherattrib($id, $value); $ok = $usr->clear_session($id); $id = $ua->new_user(login => $login, passwd => $passwd, [otherattribute => $otherattribute]); $ok = $ua->remove_user($id); DESCRIPTION
User::Simple::Admin manages the administrative part of the User::Simple modules - Please check User::Simple for a general overview of these modules and an explanation on what-goes-where. User::Simple::Admin works as a regular administrator would: The module should be instantiated only once for all of your users' administration, if possible, and not instantiated once for each user (in contraposition to User::Simple, as it works from each of the users' perspective in independent instantiations). Note also that User::Simple::Admin does b<not> perform the administrative user checks - It is meant to be integrated to your system, and it is your system which should carry out all of the needed authentication checks. CONSTRUCTOR Administrative actions for User::Simple modules are handled through this Admin object. To instantiate it: $ua = User::Simple::Admin->new($db, $user_table); $db is an open connection to the database where the user data is stored. $user_table is the name of the table that holds the users' data. If we do not yet have the needed DB structure to store the user information, we can use this class method as a constructor as well: $ua = User::Simple::Admin->create_rdbms_db_structure($db, $user_table, [$extra_sql]); $ua = User::Simple::Admin->create_plain_db_structure($db, $user_table, [$extra_sql]); The first one should be used if your DBI handle ($db) points to a real RDBMS, such as PostgreSQL or MySQL. In case you are using a file- based DBD (such as DBD::XBase, DBD::DBM, DBD::CVS or any other which does not use a real RDBMS for storage), use "User::Simple::Admin->create_plain_db_structure" instead. What is the difference? In the first case, we will create a table that has internal consistency checks - Some fields are declared NOT NULL, some fields are declared UNIQUE, and the user ID is used as a PRIMARY KEY. This cannot, of course, be achieved using file-based structures, so the integrity can only be maintained from within our scripts. This module does not provide the functionality to modify the created tables by adding columns to it, although methods do exist to access and modify the values stored in those columns (see the "CREATING, QUERYING AND MODIFYING USERS" section below), as many DBDs do not implement the ALTER TABLE SQL commands. It does, however, allow you to specify extra fields in the tables at creation time - If you specify a third extra parameter, it will be included as part of the table creation - i.e., you can create a User::Simple table with fields for the user's first and family names and a UNIQUE constraint over them this way: $ua = User::Simple::Admin->create_rdbms_db_structure($db, $user_table, 'firstname varchar(30) NOT NULL, famname varchar(30) NOT NULL, UNIQUE (firstname,famname)'); Keep in mind that the internal fields are "id", "login", "passwd", "session" and "session_exp". Don't mess with them ;-) Avoid adding any fields starting with "set_" or called as any method defined here, as they will become unreachable. And, of course, keep in mind what SQL construct does your DBD support. If you add any fields with names starting with "adm_", they will be visible but not modifiable from within User::Simple - You will only be able to modify them from User::Simple::Admin. QUERYING FOR DATABASE READINESS In order to check if the database is ready to be used by this module with the specified table name, use the "has_db_structure" class method: $ok = User::Simple::Admin->has_db_structure($db, $user_table); RETRIEVING THE SET OF USERS %users = $ua->dump_users; Will return a hash with the data regarding the registered users with all of the existing DB fields, in the following form: ( $id1 => { login=>$login1, firstname=>$firstname1, famname=>$famname1 }, $id2 => { login=>$login2, firstname=>$firstname2, famname=>$famname2 }, (...) ) Of course, with the appropriate attributes. The internal attributes "id", "session" and "session_exp" will not be included in the resulting hashes (you have the "id" as the hash keys). CREATING, QUERYING AND MODIFYING USERS $id = $ua->new_user(login => $login, passwd => $passwd, [otherattribute => $otherattribute]); Creates a new user with the specified data. Returns the new user's ID. Only the login is mandatory (as it uniquely identifies the user), unless you have specified extra NOT NULL fields or constraints in the DB. If no password is supplied, the account will be created, but no login will be allowed until one is supplied. $ok = $ua->remove_user($id); Removes the user specified by the ID. $id = $ua->id($login); $login = $ua->login($id); $otherattrib = $user->otherattrib($id); Get the value of each of the mentioned attributes. Note that in order to get the ID you can supply the login, every other method answers only to the ID. In case you have the login and want to get the firstname, you can use "$ua-"firstname($ua->id($login));> Of course, beware: if you request for a field which does not exist in your table, User::Simple will raise an error and die just as if an unknown method had been called. $ok = $usr->set_login($id, $login); $ok = $usr->set_passwd($id, $passwd); Modifies the requested attribute of the specified user, setting it to the new value. Except for the login, they can all be set to null values - If the password is set to a null or empty value, the account will be locked (that is, no password will be accepted). The internal attributes "id", "session" and "session_exp" cannot be directly modified (you have the "id" as the hash keys). Just as with the accessors, if you have extra columns, you can modify them the same way: $ok = $usr->set_otherattrib($id, $value); i.e. $ok = $usr->set_name($id, $name); SESSIONS $ok = $usr->clear_session($id); Removes the session which the current user had open, if any. Note that you cannot create a new session through this module - The only way of creating a session is through the "ck_login" method of User::Simple. DEPENDS ON
Digest::MD5 SEE ALSO
User::Simple for the regular user authentication routines (that is, to use the functionality this module adimisters) AUTHOR
Gunnar Wolf <gwolf@gwolf.org> COPYRIGHT
Copyright 2005-2009 Gunnar Wolf / Instituto de Investigaciones Economicas UNAM This module is Free Software; it can be redistributed under the same terms as Perl. perl v5.10.0 2009-01-20 User::Simple::Admin(3pm)
All times are GMT -4. The time now is 06:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy