Sponsored Content
Full Discussion: Extract Field from a file
Top Forums Shell Programming and Scripting Extract Field from a file Post 302556636 by Rajesh Putnala on Monday 19th of September 2011 08:40:06 AM
Old 09-19-2011
Quote:
Originally Posted by malcomex999
Expecting your file is a plain text so try this...

Code:
awk -F\| '{for(i=0;++i<=NF;) if($i ~ /Acct/) print $i}' infile


I tried the one you have given...Thanks for the help..Its almost worked..
But I need a small correction..
Am getting the output as :

Acct 0110855565
Acct 2063947620

Can you make correction to the above solution to get the output as :
0110855565
2063947620

---------- Post updated at 07:40 AM ---------- Previous update was at 07:39 AM ----------

I tried the one you have given...Thanks for the help..Its almost worked..
But I need a small correction..
Am getting the output as :

Acct 0110855565
Acct 2063947620

Can you make correction to the above solution to get the output as :
0110855565
2063947620
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Trying to extract a field from /etc/passwd file..

Hello, was looking for some help on extracting a field from the passwd file. So far I have made a copy of the passwd file and changed my rights so I can edit it. Every user's password is coded as an :x:, and my goal was to change that x to a blank, and then try to extract any user with that field... (2 Replies)
Discussion started by: xBuRnTx
2 Replies

2. UNIX for Dummies Questions & Answers

extract a field by logic

below are the contents of file 'tmp.out': 2|34|534| 1|355|54| 1|443|34| 3|43|768| 3|7|887| 1|9|990| How do I extract the 2nd and 3rd columns of file 'tmp.out' only when the first column equals '1'. Note that this file will be huge; atleast 5million+ rows, so I want to avoid looping... (4 Replies)
Discussion started by: ChicagoBlues
4 Replies

3. Shell Programming and Scripting

how to extract last occurence of the field

path = /first/second/third/fourth. i want to extract /first/second/third from path.my program something like this .... path=/first/second/third/fourth noc=`echo $path|tr '/' '\n'|wc -w` var='echo $noc|cut -d'/' -f 1-$noc --> is giving error. why $noc is not working here.any other... (3 Replies)
Discussion started by: kcp_pavan
3 Replies

4. Shell Programming and Scripting

Extract data into file with specific field specs

:confused: I have a tab delimited file that I need to extract data from and into a file with specific field specs. Each field has to be a certain amount of characters. So, the name field (from delimited file) might have only 15 characters but needs to be 25 (in new file) so I need to insert spaces... (5 Replies)
Discussion started by: criddel
5 Replies

5. UNIX for Dummies Questions & Answers

Extract Field Value from XML file

Hi, Within a UNIX shell script I need to extract a value from an XML field. The field will contain different values but will always be 6 digits in length. E.g.: <provider-id>999999</provider-id> I've tried various ways but no luck. Any ideas how I might get the provider id (in this case... (2 Replies)
Discussion started by: pnclayt11
2 Replies

6. Shell Programming and Scripting

Extract file records based on some field conditions

Hello Friends, I have a file(InputFile.csv) with the following columns(the columns are pipe-delimited): ColA|ColB|ColC|ColD|ColE|ColF Now for this file, I have to get those records which fulfil the following condition: If "ColB" is NOT NULL and "ColD" has values one of the following... (9 Replies)
Discussion started by: mehimadri
9 Replies

7. Shell Programming and Scripting

extract data in a csv file based on a certain field.

I have a csv file that I need to extract some data from depending on another field after reading info from another text file. The text file would say have 592560 in it. The csv file may have some data like so Field 1 Field2 Field3 Field4 Field5 Field6 20009756 1 ... (9 Replies)
Discussion started by: GroveTuckey
9 Replies

8. Shell Programming and Scripting

Extract a nth field from a comma delimited file

Hi, In my file (which is "," delimited and text qualifier is "), I have to extract a particualr field. file1: 1,"aa,b",4 expected is the 2nd field: aa,b I tried the basic cut -d "," -f 2 file 1, this gave me aa alone instead aa,b. A small hint ot help on this will be very... (5 Replies)
Discussion started by: machomaddy
5 Replies

9. Shell Programming and Scripting

Extract lines whose third field is 0

Hi, I have a file with colon separated values like below. How can i get those lines whose third field is 0 (zero). In the below example, lines starting with stapler and tempo has its third field as 0 $ cat list.txt galaxy:b:5:world stapler:a:0:hello abc:a:4:stomper kepler:uic:5:jam... (8 Replies)
Discussion started by: John K
8 Replies

10. UNIX for Beginners Questions & Answers

Command to extract empty field in a large UNIX file?

Hi All, I have records in unix file like below. In this file, we have empty fields from 4th Column to 22nd Column. I have some 200000 records in a file. I want to extract records only which have empty fields from 4th field to 22nd filed. This file is comma separated file. what is the unix... (2 Replies)
Discussion started by: rakeshp
2 Replies
Mail::Field::AddrList(3)				User Contributed Perl Documentation				  Mail::Field::AddrList(3)

NAME
Mail::Field::AddrList - object representation of e-mail address lists INHERITANCE
Mail::Field::AddrList is a Mail::Field SYNOPSIS
use Mail::Field::AddrList; $to = Mail::Field->new('To'); $from = Mail::Field->new('From', 'poe@daimi.aau.dk (Peter Orbaek)'); $from->create('foo@bar.com' => 'Mr. Foo', poe => 'Peter'); $from->parse('foo@bar.com (Mr Foo), Peter Orbaek <poe>'); # make a RFC822 header string print $from->stringify()," "; # extract e-mail addresses and names @addresses = $from->addresses(); # strings @names = $from->names(); # strings @addr = $from->addr_list(); # Mail::Address objects (v2.00) # adjoin a new address to the list $from->set_address('foo@bar.com', 'Mr. Foo'); DESCRIPTION
Defines parsing and formatting of address field, for the following fields: "To", "From", "Cc", "Reply-To", and "Sender". All the normally used features of the address field specification of RFC2822 are implemented, but some complex (and therefore hardly ever used) constructs will not be inderstood. Use Mail::Message::Field::Full in MailBox if you need full RFC compliance. METHODS
Constructors Mail::Field::AddrList->combine(FIELDS) See "Constructors" in Mail::Field Mail::Field::AddrList->extract(TAG, HEAD [, INDEX ]) See "Constructors" in Mail::Field Mail::Field::AddrList->new(TAG [, STRING | OPTIONS]) See "Constructors" in Mail::Field "Fake" constructors $obj->create(OPTIONS) See ""Fake" constructors" in Mail::Field $obj->parse() See ""Fake" constructors" in Mail::Field Accessors $obj->set(OPTIONS) See "Accessors" in Mail::Field $obj->stringify() See "Accessors" in Mail::Field $obj->tag() Mail::Field::AddrList->tag() See "Accessors" in Mail::Field Smart accessors $obj->addr_list() Returns the collected Mail::Address objects. $obj->addresses() Returns a list if email addresses, found in the field content. $obj->names() Returns a list of nicely formatted named, for each of the addresses found in the content. $obj->set_address(EMAIL, NAME) Add/replace an EMAIL address to the field. $obj->text([STRING]) See "Smart accessors" in Mail::Field DIAGNOSTICS
Error: Undefined subroutine <method> called Mail::Field objects use autoloading to compile new functionality. Apparently, the mehod called is not implemented for the specific class of the field object. SEE ALSO
This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/. AUTHORS
The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. For other contributors see ChangeLog. LICENSE
Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark Overmeer <perl@overmeer.net>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.16.3 2012-12-21 Mail::Field::AddrList(3)
All times are GMT -4. The time now is 07:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy