09-02-2003
Help with greping a field
Hi,
Suppose I have a file as below and I just want the field Invoice Number from this file , How can I do it.
/home/arbor>cat PH0034090202314800030IM-001
0Yp825XMilperra NSW 1891 189110H14V1Sp2871Yp300X Customer Service : 0000-368-81118H6.5V0Sp3130Yp50X For Australian GST purposes, when an amount of GST is expressed in a currency otherp3173Yp50X than AUD, this amount should be converted to AUS at the exchange rate publishedp3216Yp50X by the RBA at 4:00pm AEST on the same day as the date of this invoicep3302Yp50X Hanoi Australia Pty Ltdp3345Yp50X ABN: 00000000000p3388Yp50X 203 Military Road, St Leonards, Sydney NSW 2065
5H36V1Sp204Yp1734XInvoice12H9V0S0Bp419Yp50XAccount No:0P16.67H9.5V6Tp419Yp325XAUID132291P12H9V16602Tp505Yp50XName:0P16.67H9.5V6Tp505Yp325XSturdy Components Pty Ltdp548Yp325XATTN Mr g Kwohp591Yp325XP O Box 0035p634Yp325Xxxxxxx NSW 1891 18911P12H9V16602Tp419Yp1375XPage
505Yp1375XInvoice Number:0P16.67H9.5V6Tp505Yp1750X13539391P12H9V16602Tp548Yp1375XInvoice Date:0P16.67H9.5V6Tp548Yp1750X08-Jan-011P12H9V16602Tp591Yp1375XBilling Period:0P16.67H9.5V6Tp591Yp1750X01-Dec-00 - 31-Dec-001P12H12V3B16602Tp892Yp969XInvoice p505Yp1375XInvoice Number:0P16.67H9.5V6Tp505Yp1750X13539391P12H9V16602Tp548Yp1375XInvoice Summary9Vp978Yp1023XRemittance Copy0Bp1021Yp759XPlease Return This Remittance With Payment To:0P16.67H9.5V6Tp1107Yp941XHanoi Australia Pty Ltdp1150Yp941XATTN: Accounts Receivablep1193Yp1067XGPO Box 5115p1236Yp1031XSydney NSW 2001p1279Yp1085XAustralia1P12H9V3B16602Tp1408Yp625XNew Charges(GST exclusive)0P16.67H9.5V0B6Tp1408Yp1570XAUD 197.551P12H9V3B16602Tp1451Yp625XNet Total Charges(GST exclusive)0P16.67H9.5V0B6Tp1451Yp1570XAUD 197.551P12H9V3B16602Tp1495Yp625XTaxes - GST @ 10.0 %0P16.67H9.5V0B6Tp1495Yp1588XAUD 19.761P12H9V3B16602Tp1538Yp625XTotal New Charges(GST inclusive)0P16.67H9.5V0B6Tp1538Yp1570XAUD 217.311P12H9V16602Tp1624Yp924XPayment Due Date 10-Feb-0118H6.5V3Bp3130Yp50X
Invoice Number:0P16.67H9.5V6Tp505Yp1750X13539391P12H9V16602Tp548Yp1375X
Your help will be highly appreciated
Last edited by rooh; 09-02-2003 at 01:32 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I just had a filesystem / file corruption issue on my HSP's server due to disk capacity limits and fileswapping. I discovered that certain files got corrupted when fileswapping was not successful and they ended up with a string of control characters, or what I believe to be nulls, in them.
Does... (4 Replies)
Discussion started by: Dr. DOT
4 Replies
2. Shell Programming and Scripting
One of my outout is like this as shown below. How can I grep only the lines after the line "Affected files ...". No of lines after the line "Affected files ..." may vary.
$ cat file_A
Change 149133 by csaha@test_depo_csaha on 2006/02/08 01:40:57 *pending*
This is to test change #... (5 Replies)
Discussion started by: csaha
5 Replies
3. Shell Programming and Scripting
i have a ksh script :
#!/bin/ksh
TZ=`date +%Z`+24 ;a=`date +%Y-%m-%d`
b=`date +"%H:%M:%S"`
cd /ednadtu3/u01/pipe/logs
for i in Archiver1.log
do
cat $i | grep $a | grep $b >> /ednadtu3/u01/pipe/naveed/Insert_Date.txt
done... (4 Replies)
Discussion started by: ali560045
4 Replies
4. Shell Programming and Scripting
Hi Friends,
Urgently required to know this :
I have a file which has several stanzas like below :
CuDv:
name = "hdisk3"
status = 1
chgstatus = 2
ddins = "scdisk"
location = "03-08-01-11,0"
parent = "scsi1"
connwhere =... (3 Replies)
Discussion started by: vijaya2006
3 Replies
5. Shell Programming and Scripting
I have this line
BTSRTRGRP-448-1-1 10.162.141.118/255.255.255.254 -
I need to print only the IPADDRESS and not the subnet mask. If i use cut -c30-43 I get the ipaddress, where as in some cases if the last octet is of single digit (10.162.141.8/255.255.255.254) it... (2 Replies)
Discussion started by: miltonrods
2 Replies
6. Shell Programming and Scripting
I know you could use the grep "something" -A200 flag to get all the lines past your pattern. Is there a way to get all the lines in between two patterns? The -a flag will not work since all lines in between the two patterns don't have a constant number. (4 Replies)
Discussion started by: jwillis0720
4 Replies
7. Shell Programming and Scripting
Hi,
i have to find a string in a file and positin of the string in the file would come in some particular interval.
let's say file is 1-1000 lines and string is in from 200-300line.
could any one suggest me how to get make the grep search for the string in that particular portion of the... (4 Replies)
Discussion started by: tarakant
4 Replies
8. Shell Programming and Scripting
Hi
When I run this command:
lsuser -a auditclasses ALL
I got:
user1 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert
user2 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert
user3 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert
user4... (7 Replies)
Discussion started by: iga3725
7 Replies
9. Shell Programming and Scripting
Hi Folks,
I am searching something in multiple logs , actually an even ocuurs which get recorded in logs with a special word so rite now I am opening an individual log in vi and then searching it but total in the directory there are such 15 logs and it is very difficult to go one by one so... (1 Reply)
Discussion started by: punpun66
1 Replies
10. Shell Programming and Scripting
i want to grab lines from a file that are between two patterns (including the lines that contain the pattern).
here's what im currently doing:
data.txt
aaa
bbb
cccc
ddd
eee
ffff
ddd
code:
awk '/bbb/,/fff/ && $0 !~ /ddd/' cdsnmp.sh
I want to grab lines between and including bbb... (5 Replies)
Discussion started by: SkySmart
5 Replies
LEARN ABOUT REDHAT
regexp_table
REGEXP_TABLE(5) File Formats Manual REGEXP_TABLE(5)
NAME
regexp_table - format of Postfix regular expression tables
SYNOPSIS
regexp:/etc/postfix/filename
DESCRIPTION
The Postfix mail system uses optional tables for address rewriting or mail routing. These tables are usually in dbm or db format. Alterna-
tively, lookup tables can be specified in POSIX regular expression form.
To find out what types of lookup tables your Postfix system supports use the postconf -m command.
The general form of a Postfix regular expression table is:
pattern result
When pattern matches a search string, use the corresponding result.
blank lines and comments
Empty lines and whitespace-only lines are ignored, as are lines whose first non-whitespace character is a `#'.
multi-line text
A logical line starts with non-whitespace text. A line that starts with whitespace continues a logical line.
pattern1!pattern2 result
Matches pattern1 but not pattern2.
Each pattern is a regular expression enclosed by a pair of delimiters. The regular expression syntax is described in re_format(7). The
expression delimiter can be any character, except whitespace or characters that have special meaning (traditionally the forward slash is
used). The regular expression can contain whitespace.
By default, matching is case-insensitive, although following the second slash with an `i' flag will reverse this. Other flags are `x' (dis-
able extended expression syntax), and `m' (enable multi-line mode).
Each pattern is applied to the entire lookup key string. Depending on the application, that string is an entire client hostname, an entire
client IP address, or an entire mail address. Thus, no parent domain or parent network search is done, and user@domain mail addresses are
not broken up into their user and domain constituent parts, nor is user+foo broken up into user and foo.
Patterns are applied in the order as specified in the table, until a pattern is found that matches the search string.
Substitution of substrings from the matched expression into the result string is possible using $1, $2, etc.. The macros in the result
string may need to be written as ${n} or $(n) if they aren't followed by whitespace.
EXAMPLE SMTPD ACCESS MAP
# Disallow sender-specified routing. This is a must if you relay mail
# for other domains.
/[%!@].*[%!@]/ 550 Sender-specified routing rejected
# Postmaster is OK, that way they can talk to us about how to fix
# their problem.
/^postmaster@/ OK
# Protect your outgoing majordomo exploders
/^(.*)-outgoing@(.*)$/!/^owner-/ 550 Use ${1}@${2} instead
EXAMPLE HEADER FILTER MAP
# These were once common in junk mail.
/^Subject: make money fast/ REJECT
/^To: friend@public.com/ REJECT
SEE ALSO
pcre_table(5) format of PCRE tables
AUTHOR(S)
The regexp table lookup code was originally written by:
LaMont Jones
lamont@hp.com
That code was based on the PCRE dictionary contributed by:
Andrew McNamara
andrewm@connect.com.au
connect.com.au Pty. Ltd.
Level 3, 213 Miller St
North Sydney, NSW, Australia
Adopted and adapted by:
Wietse Venema
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA
REGEXP_TABLE(5)