Sponsored Content
Top Forums UNIX for Dummies Questions & Answers regex - display all occurrences of match Post 302288470 by tektips on Tuesday 17th of February 2009 09:51:46 AM
Old 02-17-2009
Thanks vgersh99 for all your help.

Tried this out and For me, catch with this is it does not yield be the table name ( string after the period).

When I run the script on my test file, my result set is

ABCD_PL_OFR_TB.
ABCD_PROBE_TB.
ABCD_PROHIT_TB.
ABCD_RETMAIL_TB.
ABCD_RWD_TB.
ABCD_SOL_TB.
ABCD_STG_TB.
ABCD_STMT_AGGN_TB.

What I am actually looking to get is

ABCD_PL_OFR_TB.TABLE_A_B
ABCD_PROBE_TB.TABLE_B
ABCD_PROHIT_TB.TABLE_C_K
ABCD_RETMAIL_TB.TABLE_D
ABCD_RWD_TB.TABLE_E_J_H
ABCD_SOL_TB.TABLE_F_N
ABCD_STG_TB.TABLE_G_H_K_L
ABCD_STMT_AGGN_TB.TABLE_H

Also I want the script to be able to capture instances of strings like ABCD.TABLE_A_B_C as well. ( ABCD followed by a period and a Table Name)

Would appreciate your guidance





Quote:
Originally Posted by vgersh99
assuming tec.txt:
Code:
aaaaaaaaaa ABCD_EFGH_XYZ.Table_Name1 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbb ABCD_EFGH_XYZ.Table_Name1 cccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccc ABCD_EFGH_XYZ.Table_Name2 ddddddddddddddd
aaaaaaaaaa ABCD_XYZ_EFGH.Table_Name1 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
aaaaaaaaaa ABCD_XYZ_1234.Table_Name1 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbb ABCD_EFGH_XYZ.ORDER_SUMM cccccccccccccccccccccccccccccccccccccccc
bbbbbbbbbb ABCD_EFGH_XYZ.PAYMENT_DETAIL cccccccccccccccccccccccccccccccccccccccc
bbbbbbbbbb ABCD_EFGH_XYZ.ORDER_SUMM cccccccccccccccccccccccccccccccccccccccc

and previously posted test.awk:
Code:
#!/usr/bin/nawk -f
{
    while (match($0, pat)) {
       printf("%s\n", substr($0, RSTART, RLENGTH) OFS);
       $0=substr($0, RSTART+RLENGTH)
    }
}

test.awk -v pat='ABCD[A-Za-z_.][A-Za-z_.]*' tec.txt
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

regex to match basename

Hi Can somebody please help me know how do i match the basename using a regular expression using posix standard in shell script suppose i want to match /u01/Sybase/data/master.dbf the result should be master.dbf as i want to match everything after the last / regards (8 Replies)
Discussion started by: xiamin
8 Replies

2. UNIX for Advanced & Expert Users

Regex to match IP address

What do you think of this regex to match IP address? I have been reading up on regex and have seen some really long ones for IP. Would this fail in any scenarios? (+\.){3}* (5 Replies)
Discussion started by: glev2005
5 Replies

3. UNIX for Dummies Questions & Answers

awk display the match and 2 lines after the match is found.

Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file. For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt I tried with grep -A but it's not supported on my system. I tried with awk,... (4 Replies)
Discussion started by: eurouno
4 Replies

4. Shell Programming and Scripting

Regex find first 5-7 occurrences of a set of digits within a string

Using these strings as an example: <a onclick="doShowCHys=1;ShowWindowN(0,'/daman/man.php?asv4=145148&amp;playTogether=True',960,540,943437);return false;" title=""> <a onclick="doShowCHys=1;ShowWindowN(0,'/daman/man.php?asv4=1451486&amp;playTogether=True',960,540,94343);return false;" title=""> <a... (12 Replies)
Discussion started by: metallica1973
12 Replies

5. Shell Programming and Scripting

Only Regex pattern match help

Hi We have a tool to monitor logs in our environment. The tool accepts log pattern match only using regex and I accept I am a n00b in that:confused:. I had been banging my head to make it work without much success and at last had to turn on to my last option to post it here. I had got great... (2 Replies)
Discussion started by: radioactive9
2 Replies

6. Shell Programming and Scripting

Print occurrences for pattern match

Hi All, I want to print all the occurrences for a particular pattern from a file. The catch is that the pattern search is partial and if any word in the file contains the pattern, that complete word has to be printed. If there are multiple words matching the pattern on a specific line, then all... (2 Replies)
Discussion started by: decci_7
2 Replies

7. UNIX for Advanced & Expert Users

sed REGEX to print multiple occurrences of a pattern from a line

I have a line that I need to parse through and extract a pattern that occurs multiple times in it. Example line: getInfoCall: info received please proceed, getInfoCall: info received please proceed, getInfoCall: info received please proceed, getInfoCall: info received please proceed,... (4 Replies)
Discussion started by: Vidhyaprakash
4 Replies

8. Shell Programming and Scripting

Display match or no match and write a text file to a directory

The below bash connects to a site, downloads a file, searches that file based of user input - could be multiple (all that seems to work). What I am not able to figure out is how to display on the screen match found or no match found" and write a file to a directory (C:\Users\cmccabe\Desktop\wget)... (4 Replies)
Discussion started by: cmccabe
4 Replies

9. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

10. Shell Programming and Scripting

Count the number of string occurrences to display 0 entries in output

Hello Friends, Can somebody assist an issue I am having? I have a separate file with a list of account ids XXX200B02Y01 XXX200B03Y01 XXX200B05Y01 XXX200B07Y01 XXX200B08Y01 I call the file, and run an egrep against a directory and logfiles AccountID=$(cat... (2 Replies)
Discussion started by: liketheshell
2 Replies
GITNAMESPACES(7)						    Git Manual							  GITNAMESPACES(7)

NAME
gitnamespaces - Git namespaces SYNOPSIS
GIT_NAMESPACE=<namespace> git upload-pack GIT_NAMESPACE=<namespace> git receive-pack DESCRIPTION
Git supports dividing the refs of a single repository into multiple namespaces, each of which has its own branches, tags, and HEAD. Git can expose each namespace as an independent repository to pull from and push to, while sharing the object store, and exposing all the refs to operations such as git-gc(1). Storing multiple repositories as namespaces of a single repository avoids storing duplicate copies of the same objects, such as when storing multiple branches of the same source. The alternates mechanism provides similar support for avoiding duplicates, but alternates do not prevent duplication between new objects added to the repositories without ongoing maintenance, while namespaces do. To specify a namespace, set the GIT_NAMESPACE environment variable to the namespace. For each ref namespace, Git stores the corresponding refs in a directory under refs/namespaces/. For example, GIT_NAMESPACE=foo will store refs under refs/namespaces/foo/. You can also specify namespaces via the --namespace option to git(1). Note that namespaces which include a / will expand to a hierarchy of namespaces; for example, GIT_NAMESPACE=foo/bar will store refs under refs/namespaces/foo/refs/namespaces/bar/. This makes paths in GIT_NAMESPACE behave hierarchically, so that cloning with GIT_NAMESPACE=foo/bar produces the same result as cloning with GIT_NAMESPACE=foo and cloning from that repo with GIT_NAMESPACE=bar. It also avoids ambiguity with strange namespace paths such as foo/refs/heads/, which could otherwise generate directory/file conflicts within the refs directory. git-upload-pack(1) and git-receive-pack(1) rewrite the names of refs as specified by GIT_NAMESPACE. git-upload-pack and git-receive-pack will ignore all references outside the specified namespace. The smart HTTP server, git-http-backend(1), will pass GIT_NAMESPACE through to the backend programs; see git-http-backend(1) for sample configuration to expose repository namespaces as repositories. For a simple local test, you can use git-remote-ext(1): git clone ext::'git --namespace=foo %s /tmp/prefixed.git' SECURITY
Anyone with access to any namespace within a repository can potentially access objects from any other namespace stored in the same repository. You can't directly say "give me object ABCD" if you don't have a ref to it, but you can do some other sneaky things like: 1. Claiming to push ABCD, at which point the server will optimize out the need for you to actually send it. Now you have a ref to ABCD and can fetch it (claiming not to have it, of course). 2. Requesting other refs, claiming that you have ABCD, at which point the server may generate deltas against ABCD. None of this causes a problem if you only host public repositories, or if everyone who may read one namespace may also read everything in every other namespace (for instance, if everyone in an organization has read permission to every repository). Git 1.8.5.3 01/14/2014 GITNAMESPACES(7)
All times are GMT -4. The time now is 08:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy