Sponsored Content
Top Forums Shell Programming and Scripting How to extract 4th field if numerics? Post 302746861 by Jairaj on Thursday 20th of December 2012 06:02:26 AM
Old 12-20-2012
Try this :
Code:
awk -F',"' '{print int($4)}' file

---------- Post updated at 06:02 AM ---------- Previous update was at 06:01 AM ----------

Sorry about my previous command.

Code:
awk -F',"' '{ if (int($4) > 0) print $0}' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Drop records with non-numerics in field X

I have tab delimited file and need to remove all records prior to sort, that have non-numerics in the Field 2. valid/invalid field 2 data examples are: " 123" valid "1 23" invalid " NOPE" invalid I've tried this awk it does not recognize tab as the delimiter or check... (3 Replies)
Discussion started by: akxeman
3 Replies

2. AIX

display file where 4th field = 200704

Hello I have a file which is pipe delimited. The 4 th field has value like 200704 or 200705 etc. Now i have to get only those records where 4th field is 200704 How can i do this? I have to get the whole record where 4th field = 200704 (4 Replies)
Discussion started by: vasuarjula
4 Replies

3. Shell Programming and Scripting

display file where 4th field = 200704

Hello I have a file which is pipe delimited. The 4 th field has value like 200704 or 200705 etc. Now i have to get only those records where 4th field is 200704 How can i do this? I have to get the whole record where 4th field = 200704 (7 Replies)
Discussion started by: vasuarjula
7 Replies

4. Shell Programming and Scripting

How to extract 3rd line 4th column of a file

Hi, Shell script: I would need help on How to extract 3rd line 4th column of a file with single liner Thanks in advance. (4 Replies)
Discussion started by: krishnamurthig
4 Replies

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

6. Shell Programming and Scripting

Replace 4th field if null

Hi .. Can some one please suggest me how to replace 4th field(column) of a .csv file with "NA" if it is null. Input file data: |A|21|B1||1.1| |A|21|C|RAGH|1.1| |A|21|D1||1.1| |A|21|C|YES|1.1 Expected Output |A|21|B1|NA|1.1| |A|22|C|RAGH|1.1| |B|23|D1|NA|1.1| |A|24|C|YES|1.1| Thank... (4 Replies)
Discussion started by: pasupuleti81
4 Replies

7. Shell Programming and Scripting

Extract Field from a file

I have an input file with content like : 18:51:18 | 217863|Acct 0110855565|RC 17608| 16 Subs| 1596 UsgRecs| 2 Secs| 430 CPUms| prmis2:26213 <MoveUsage d aemon needs to run on this account before it can be billed.> 23:03:30 | 896529|Acct 2063947620|RC 17608| 8 Subs| 148 UsgRecs| ... (9 Replies)
Discussion started by: Rajesh Putnala
9 Replies

8. Shell Programming and Scripting

How to extract 3rd,4th and 5th element

Hi All! I trying to execute this perl script to extract a particular field in a text file, luckily it works. But, right now I would like to extract 3 more fields in the text file but couldnt get the right syntax on how to do it. command is: perl -pe '$_ = (split(//)) . "\n"' TestDoc.txt... (3 Replies)
Discussion started by: VicNetIT
3 Replies

9. Shell Programming and Scripting

perl script to split the text file after every 4th field

I had a text file(comma seperated values) which contains as below 196237,ram,25-May-06,ram.kiran@xyz.com,204183,Pavan,4-Jun-07,Pavan.Desai@xyz.com,237107,ram Chandra,15-Mar-10,ram.krishna@xyz.com ... (3 Replies)
Discussion started by: giridhar276
3 Replies

10. 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
MIME::Field::ParamVal(3)				User Contributed Perl Documentation				  MIME::Field::ParamVal(3)

NAME
MIME::Field::ParamVal - subclass of Mail::Field, for structured MIME fields SYNOPSIS
# Create an object for a content-type field: $field = new Mail::Field 'Content-type'; # Set some attributes: $field->param('_' => 'text/html'); $field->param('charset' => 'us-ascii'); $field->param('boundary' => '---ABC---'); # Same: $field->set('_' => 'text/html', 'charset' => 'us-ascii', 'boundary' => '---ABC---'); # Get an attribute, or undefined if not present: print "no id!" if defined($field->param('id')); # Same, but use empty string for missing values: print "no id!" if ($field->paramstr('id') eq ''); # Output as string: print $field->stringify, " "; DESCRIPTION
This is an abstract superclass of most MIME fields. It handles fields with a general syntax like this: Content-Type: Message/Partial; number=2; total=3; id="oc=jpbe0M2Yt4s@thumper.bellcore.com" Comments are supported between items, like this: Content-Type: Message/Partial; (a comment) number=2 (another comment) ; (yet another comment) total=3; id="oc=jpbe0M2Yt4s@thumper.bellcore.com" PUBLIC INTERFACE
set [\%PARAMHASH | KEY=>VAL,...,KEY=>VAL] Instance method. Set this field. The paramhash should contain parameter names in all lowercase, with the special "_" parameter name signifying the "default" (unnamed) parameter for the field: # Set up to be... # # Content-type: Message/Partial; number=2; total=3; id="ocj=pbe0M2" # $conttype->set('_' => 'Message/Partial', 'number' => 2, 'total' => 3, 'id' => "ocj=pbe0M2"); Note that a single argument is taken to be a reference to a paramhash, while multiple args are taken to be the elements of the paramhash themselves. Supplying undef for a hashref, or an empty set of values, effectively clears the object. The self object is returned. parse_params STRING Class/instance utility method. Extract parameter info from a structured field, and return it as a hash reference. For example, here is a field with parameters: Content-Type: Message/Partial; number=2; total=3; id="oc=jpbe0M2Yt4s@thumper.bellcore.com" Here is how you'd extract them: $params = $class->parse_params('content-type'); if ($$params{'_'} eq 'message/partial') { $number = $$params{'number'}; $total = $$params{'total'}; $id = $$params{'id'}; } Like field names, parameter names are coerced to lowercase. The special '_' parameter means the default parameter for the field. NOTE: This has been provided as a public method to support backwards compatibility, but you probably shouldn't use it. parse STRING Class/instance method. Parse the string into the instance. Any previous information is wiped. The self object is returned. May also be used as a constructor. param PARAMNAME,[VALUE] Instance method. Return the given parameter, or undef if it isn't there. With argument, set the parameter to that VALUE. The PARAMNAME is case-insensitive. A "_" refers to the "default" parameter. paramstr PARAMNAME,[VALUE] Instance method. Like param(): return the given parameter, or empty if it isn't there. With argument, set the parameter to that VALUE. The PARAMNAME is case-insensitive. A "_" refers to the "default" parameter. stringify Instance method. Convert the field to a string, and return it. tag Instance method, abstract. Return the tag for this field. SEE ALSO
Mail::Field perl v5.16.2 2012-06-08 MIME::Field::ParamVal(3)
All times are GMT -4. The time now is 04:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy