Sponsored Content
Top Forums Shell Programming and Scripting need to extract field of characters in a line Post 302198160 by jansat on Thursday 22nd of May 2008 09:07:39 AM
Old 05-22-2008
need to extract field of characters in a line

Hello,

Below is my input file's content ( in HP-UX platform ):

ABCD120672-B21 1
ABCD142257-002 1
ABCD142257-003 1
ABCD142257-006 1

From the above, I just want to get the field of 13 characters that comes after 'ABCD' i.e '120672-B21'... . Could you please let me know the shell script that I have to use?

Thanks
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK line by line instead of field by field?

I've been using a lot of awk lately for csv files. But I've been using awk for csv files that contain 32 fields per line. For the first time, I've been given a csv file that contains one field per line (13 fields in each csv file). I need to check that a specific field, or line contains a... (2 Replies)
Discussion started by: yongho
2 Replies

2. HP-UX

extract field of characters after a specific pattern - using UNIX shell script

Hello, Below is my input file's content ( in HP-UX platform ): ABCD120672-B21 1 ABCD142257-002 1 ABCD142257-003 1 ABCD142257-006 1 From the above, I just want to get the field of 13 characters that comes after 'ABCD' i.e '120672-B21'... . Could... (2 Replies)
Discussion started by: jansat
2 Replies

3. Shell Programming and Scripting

TO Extract Last 10 Characters from a line

Hi Guys!!!!!!!!!!! How do we extract last 13 characters from a line I/p: .R1/new/sv902a.01.per O/p: sv902a.01.per And the no of characters differs in each line.. Kindly help me out in this!!!!!!!!!!! Thanks in Advance (4 Replies)
Discussion started by: aajan
4 Replies

4. UNIX Desktop Questions & Answers

Extract third field of third line

Hi, how do I extract the third field of the first line? I know how to get the first line or the third field of a file, but I can't get the single entry. awk 'NR==1' file.txt awk '{print $3}' file.txt Please tell me how to combine these. And how do I set this value into a variable? ... (1 Reply)
Discussion started by: etownbetty
1 Replies

5. Shell Programming and Scripting

Compare Field in Current Line with Field in Previous

Hi Guys I have the following file Essentially, I am trying to find the right awk/sed syntax in order to produce the following 3 distinct files from the file above: Basically, I want to print the lines of the file as long as the second field of the current line is equal to the... (9 Replies)
Discussion started by: moutaye
9 Replies

6. Shell Programming and Scripting

sed to replace a field from a line with another field

i have something like this, cat filename.txt hui this si s"dfgdfg" omeone ipaddress="10.19.123.104" wel hope this works i want to replace only 10.19.123.104 with different ip say 10.19.123.103 i tried this sed -i "s/'ipaddress'/'ipaddress=10.19.123.103'/g" filename.txt ... (1 Reply)
Discussion started by: vivek d r
1 Replies

7. Shell Programming and Scripting

Search for a pattern,extract value(s) from next line, extract lines having those extracted value(s)

I have hundreds of files to process. In each file I need to look for a pattern then extract value(s) from next line and then search for value(s) selected from point (2) in the same file at a specific position. HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

8. UNIX for Dummies Questions & Answers

awk if one field has more characters than another

Hi all, I've been stuck on how to write a command in awk that looks at two columns and only prints entries where one of the columns has more than or less than a 3 character difference. I need to be able to compare any two columns preferably, but as an example, comparing columns 3 and 4 example... (9 Replies)
Discussion started by: torchij
9 Replies

9. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies
Mail::Field(3)						User Contributed Perl Documentation					    Mail::Field(3)

NAME
Mail::Field - Base class for manipulation of mail header fields INHERITANCE
Mail::Field is extended by Mail::Field::AddrList Mail::Field::Date Mail::Field::Generic SYNOPSIS
use Mail::Field; my $field = Mail::Field->new('Subject', 'some subject text'); my $field = Mail::Field->new(Subject => 'some subject text'); print $field->tag,": ",$field->stringify," "; my $field = Mail::Field->subject('some subject text'); DESCRIPTION
"Mail::Field" creates and manipulates fields in MIME headers, collected within a Mail::Header object. Different field types have their own sub-class (extension), defining additional useful accessors to the field content. People are invited to merge their implementation to special fields into MailTools, to maintain a consistent set of packages and documentation. METHODS
Constructors Mail::Field (and it's sub-classes) define several methods which return new objects. These can all be categorized as constructor. Mail::Field->combine(FIELDS) Take a LIST of "Mail::Field" objects (which should all be of the same sub-class) and create a new object in that same class. Mail::Field->extract(TAG, HEAD [, INDEX ]) Takes as arguments the tag name, a "Mail::Head" object and optionally an index. If the index argument is given then "extract" will retrieve the given tag from the "Mail::Head" object and create a new "Mail::Field" based object. undef will be returned in the field does not exist. If the index argument is not given the result depends on the context in which "extract" is called. If called in a scalar context the result will be as if "extract" was called with an index value of zero. If called in an array context then all tags will be retrieved and a list of "Mail::Field" objects will be returned. Mail::Field->new(TAG [, STRING | OPTIONS]) Create an object in the class which defines the field specified by the TAG argument. "Fake" constructors $obj->create(OPTIONS) This constructor is used internally with preprocessed field information. When called on an existing object, its original content will get replaced. $obj->parse() Parse a field line. Accessors $obj->set(OPTIONS) Change the settings (the content, but then smart) of this field. $obj->stringify() Returns the field as a string. $obj->tag() Mail::Field->tag() Return the tag (in the correct case) for this item. Well, actually any casing is OK, because the field tags are treated case- insensitive; however people have some preferences. Smart accessors $obj->text([STRING]) Without arguments, the field is returned as stringify() does. Otherwise, the STRING is parsed with parse() to replace the object's content. It is more clear to call either stringify() or parse() directly, because this method does not add additional processing. DETAILS
SUB-CLASS PACKAGE NAMES All sub-classes should be called Mail::Field::name where name is derived from the tag using these rules. o Consider a tag as being made up of elements separated by '-' o Convert all characters to lowercase except the first in each element, which should be uppercase. o name is then created from these elements by using the first N characters from each element. o N is calculated by using the formula :- int((7 + #elements) / #elements) o name is then limited to a maximum of 8 characters, keeping the first 8 characters. For an example of this take a look at the definition of the "_header_pkg_name()" subroutine in "Mail::Field" DIAGNOSTICS
Error: Undefined subroutine <method> called Mail::Field objects use autoloading to compile new functionality. Apparently, the method 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.18.2 2014-01-05 Mail::Field(3)
All times are GMT -4. The time now is 02:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy