Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Retrieve 5th Field to Last Field !! Post 302117578 by jobbyjoseph on Tuesday 15th of May 2007 11:50:56 AM
Old 05-15-2007
Retrieve 5th Field to Last Field !!

I have a script which retrieves certain fields from a text file using awk. The delimiter used is white space.

cat /home/eis/boss/OPS|while read LINE
do
crdno=`echo $LINE | awk '{print $1}'`
atm=`echo $LINE | awk '{print $2}'`
seq=`echo $LINE | awk '{print $3}'`
amount=`echo $LINE | awk '{print $8}'`
rec=`echo "CARD NO:$crdno ATM ID:$atm AMOUNT:$amount SEQ:$seq"`
done
Problem now is that we have a new field added in the text file which has to be retrieved. This field has addresses as values and as such there are white spaces in this field in the addresses. The address field starts at position no. 8 and is the last field as such but due to the white spaces between the values in this field I cannot retrieve the 8th Field without losing out some portion of values due to the white space between them.
eg:
FIELD1 FIELD2 FIELD3 FIELD8
a 21 400 EVERGLADES 20/A
b 22 5000 FLIPSYDE-REGION
c 23 650 GREEN DAY ROCKS

I need to retrieve from the 8th Field to whatever is the last field. Any suggestions on the same ?? Smilie

Regds,
Jobby
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sort alpha on 1st field, numerical on 2nd field (sci notation)

I want to sort alphabetically on the first field and sort in descending numerical order on the 2nd field. With a normal "sort -r -n" it does this: abc ||| 5e-05 ||| bla abc ||| 3 ||| ble def ||| 1 ||| abc def ||| 0.2 ||| def As you can see it ignores the fact that 5e-05 is actually 0.00005... (1 Reply)
Discussion started by: FrancoisCN
1 Replies

2. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies

3. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

4. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

5. Shell Programming and Scripting

How to remove alphabets/special characters/space in the 5th field of a tab delimited file?

Thank you for 4 looking this post. We have a tab delimited file where we are facing problem in a lot of funny character. I have tried using awk but failed that is not working. In the 5th field ID which is supposed to be a integer only of that file, we are getting corrupted data as below. I... (12 Replies)
Discussion started by: Srithar
12 Replies

6. Shell Programming and Scripting

Trying to get 5th field from ls -l output

Bash Shell/Oracle Linux 6.4 Following is an ls -lh output. Files which are equal to or higher than 1Gigabytes will displayed with G in the 5th column of the output. I am trying to find all files which are equal to or higher than 1G File sizes are shown in the 5th column. So, I tried cut -d'... (7 Replies)
Discussion started by: John K
7 Replies

7. 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

8. Shell Programming and Scripting

Display combination of 4 field uniqe record and along with concatenate 5th and 6th field.

Table ACN|NAME|CITY|CTY|NO1|NO2 115|AKKK|ASH|IND|10|15 115|AKKK|ASH|IND|20|20 115|AKKK|ASH|IND|30|35 115|AKKK|ASH|IND|30|35 112|ABC|FL|USA|15|15 112|ABC|FL|USA|25|20 112|ABC|FL|USA|25|45 i have written shell script using cut command and awk programming getting error correct it and add... (5 Replies)
Discussion started by: udhal
5 Replies

9. Shell Programming and Scripting

awk to update field using matching value in file1 and substring in field in file2

In the awk below I am trying to set/update the value of $14 in file2 in bold, using the matching NM_ in $12 or $9 in file2 with the NM_ in $2 of file1. The lengths of $9 and $12 can be variable but what is consistent is the start pattern will always be NM_ and the end pattern is always ;... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies
Mail::Message::Field::Flex(3pm) 			User Contributed Perl Documentation			   Mail::Message::Field::Flex(3pm)

NAME
Mail::Message::Field::Flex - one line of a message header INHERITANCE
Mail::Message::Field::Flex is a Mail::Message::Field is a Mail::Reporter DESCRIPTION
This is the flexible implementation of a field: it can easily be extended because it stores its data in a hash and the constructor ("new") and initializer ("init") are split. However, you pay the price in performance. Mail::Message::Field::Fast is faster (as the name predicts). OVERLOADED
overload: ""() See "OVERLOADED" in Mail::Message::Field overload: +0() See "OVERLOADED" in Mail::Message::Field overload: <=>() See "OVERLOADED" in Mail::Message::Field overload: bool() See "OVERLOADED" in Mail::Message::Field overload: cmp() See "OVERLOADED" in Mail::Message::Field METHODS
Constructors $obj->clone() See "Constructors" in Mail::Message::Field Mail::Message::Field::Flex->new(DATA) If you stick to this flexible class of header fields, you have a bit more facilities than with Mail::Message::Field::Fast. Amongst it, you can specify options with the creation. Possible arguments: o new LINE ass a LINE as it could be found in a file: a (possibly folded) line which is terminated by a new-line. o new NAME, (BODY|OBJECTS), [ATTRIBUTES], OPTIONS A set of values which shape the line. To be able to distinguish the different parameters, you will have to specify the OPTIONS as ARRAY of option pairs, or HASH of options. The ATTRIBUTES are a flat list of key-value pairs. The body is specified as one BODY string, one OBJECT, or a reference to an array of OBJECTS. See Mail::Message::Field: -Option --Defined in --Default attributes [] comment undef log Mail::Reporter 'WARNINGS' trace Mail::Reporter 'WARNINGS' attributes => ATTRS Reference to array with list of key-value pairs representing attributes, or reference to a hash containing these pairs. This is an alternative notation for specifying ATTRIBUTES directly as method arguments. comment => STRING A pre-formatted list of attributes. log => LEVEL trace => LEVEL The field $obj->isStructured() Mail::Message::Field::Flex->isStructured() See "The field" in Mail::Message::Field $obj->length() See "The field" in Mail::Message::Field $obj->nrLines() See "The field" in Mail::Message::Field $obj->print([FILEHANDLE]) See "The field" in Mail::Message::Field $obj->size() See "The field" in Mail::Message::Field $obj->string([WRAP]) See "The field" in Mail::Message::Field $obj->toDisclose() See "The field" in Mail::Message::Field Access to the name $obj->Name() See "Access to the name" in Mail::Message::Field $obj->name() See "Access to the name" in Mail::Message::Field $obj->wellformedName([STRING]) See "Access to the name" in Mail::Message::Field Access to the body $obj->body() See "Access to the body" in Mail::Message::Field $obj->folded() See "Access to the body" in Mail::Message::Field $obj->foldedBody([BODY]) See "Access to the body" in Mail::Message::Field $obj->stripCFWS([STRING]) Mail::Message::Field::Flex->stripCFWS([STRING]) See "Access to the body" in Mail::Message::Field $obj->unfoldedBody([BODY, [WRAP]]) See "Access to the body" in Mail::Message::Field Access to the content $obj->addresses() See "Access to the content" in Mail::Message::Field $obj->attribute(NAME [, VALUE]) See "Access to the content" in Mail::Message::Field $obj->attributes() See "Access to the content" in Mail::Message::Field $obj->comment([STRING]) See "Access to the content" in Mail::Message::Field $obj->study() See "Access to the content" in Mail::Message::Field $obj->toDate([TIME]) Mail::Message::Field::Flex->toDate([TIME]) See "Access to the content" in Mail::Message::Field $obj->toInt() See "Access to the content" in Mail::Message::Field Other methods $obj->dateToTimestamp(STRING) Mail::Message::Field::Flex->dateToTimestamp(STRING) See "Other methods" in Mail::Message::Field Internals $obj->consume(LINE | (NAME,BODY|OBJECTS)) See "Internals" in Mail::Message::Field $obj->defaultWrapLength([LENGTH]) See "Internals" in Mail::Message::Field $obj->fold(NAME, BODY, [MAXCHARS]) Mail::Message::Field::Flex->fold(NAME, BODY, [MAXCHARS]) See "Internals" in Mail::Message::Field $obj->setWrapLength([LENGTH]) See "Internals" in Mail::Message::Field $obj->stringifyData(STRING|ARRAY|OBJECTS) See "Internals" in Mail::Message::Field $obj->unfold(STRING) See "Internals" in Mail::Message::Field Error handling $obj->AUTOLOAD() See "Error handling" in Mail::Reporter $obj->addReport(OBJECT) See "Error handling" in Mail::Reporter $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) Mail::Message::Field::Flex->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) See "Error handling" in Mail::Reporter $obj->errors() See "Error handling" in Mail::Reporter $obj->log([LEVEL [,STRINGS]]) Mail::Message::Field::Flex->log([LEVEL [,STRINGS]]) See "Error handling" in Mail::Reporter $obj->logPriority(LEVEL) Mail::Message::Field::Flex->logPriority(LEVEL) See "Error handling" in Mail::Reporter $obj->logSettings() See "Error handling" in Mail::Reporter $obj->notImplemented() See "Error handling" in Mail::Reporter $obj->report([LEVEL]) See "Error handling" in Mail::Reporter $obj->reportAll([LEVEL]) See "Error handling" in Mail::Reporter $obj->trace([LEVEL]) See "Error handling" in Mail::Reporter $obj->warnings() See "Error handling" in Mail::Reporter Cleanup $obj->DESTROY() See "Cleanup" in Mail::Reporter $obj->inGlobalDestruction() See "Cleanup" in Mail::Reporter DIAGNOSTICS
Warning: Field content is not numerical: $content The numeric value of a field is requested (for instance the "Lines" or "Content-Length" fields should be numerical), however the data contains weird characters. Warning: Illegal character in field name $name A new field is being created which does contain characters not permitted by the RFCs. Using this field in messages may break other e-mail clients or transfer agents, and therefore mutulate or extinguish your message. Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/ LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog. 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.14.2 2012-05-07 Mail::Message::Field::Flex(3pm)
All times are GMT -4. The time now is 01:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy