Sponsored Content
Top Forums Shell Programming and Scripting Print lines that match regex on xth string Post 302757081 by black_fender on Thursday 17th of January 2013 04:34:20 AM
Old 01-17-2013
Print lines that match regex on xth string

Hello,

I need an awk command to print only the lines that match regex on xth field from file.
For example if I use this command
Code:
awk -F"|" ' $22 == "20130117090000.*" '

It wont work, I think, because single quotes wont allow the usage of the metacharacter star * . On the other hand I dont know what other syntax should I use to avoid the usage of the single quotes.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Regex to match when input is not a certain string (can't use grep -v)

Hey everyone, Basically, all I'm looking for is a way to regex for not a certain string. The regex I'm looking to avoid matching is: D222 i.e. an equivalent of: awk '!/D222/' The problem is that I use this in the following command in a Bash script: ls ${source_directory} | awk... (1 Reply)
Discussion started by: kdelok
1 Replies

2. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

3. Shell Programming and Scripting

awk to print lines based on string match on another line and condition

Hi folks, I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and... (5 Replies)
Discussion started by: rowie718
5 Replies

4. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

5. Shell Programming and Scripting

Print lines after regex

Hello, I need to print four lines inmediatly after the regexp, but not the line containing the regexp. The print should show the four lines together in one. Thanks! (13 Replies)
Discussion started by: auratus42
13 Replies

6. Shell Programming and Scripting

Nawk - print only a string containing a regex.

Hi again, I'm looking for some help with nawk, I can print a line which has a regex match in it from a file using /pattern/ but I'm looking for a way to only print the $tring which contains the pattern, rather than the whole line. This $tring may be of variable length, may occur at any point... (1 Reply)
Discussion started by: spynappels
1 Replies

7. Shell Programming and Scripting

perl regex string match issue..kindly help

i have a script in which i need to skip comments, and i am able to achieve it partially... IN text file: {**************************** {test : test...test } Script: while (<$fh>) { push ( @data, $_); } if ( $data =~ m/(^{\*+$)/ ){ } With the above match i am... (5 Replies)
Discussion started by: avskrm
5 Replies

8. Shell Programming and Scripting

Regex: print matched line and exact pattern match

Hi experts, I have a file with regexes which is used for automatic searches on several files (40+ GB). To do some postprocessing with the grep result I need the matching line as well as the match itself. I know that the latter could be achieved with grep's -o option. But I'm not aware of a... (2 Replies)
Discussion started by: stresing
2 Replies

9. UNIX for Dummies Questions & Answers

awk - (URGENT!) Print lines sort and move lines if match found

URGENT HELP IS NEEDED!! I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but - Currently, script is not printing lines to File3.txt in order. - Also the matching lines are not moving out of File1.txt ... (1 Reply)
Discussion started by: High-T
1 Replies

10. Shell Programming and Scripting

Match the value & print lines from the match

Hello, I have a file contains two columns. I need to print the lines after “xxx” so i'm trying to match "xxx" & cut the lines after that. I'm trying with the grep & cut command, if there any simple way to extract this please help me. Sample file : name id AAA 123 AAB 124 AAC 125... (4 Replies)
Discussion started by: Shenbaga.d
4 Replies
MboxParser::Mail::Body(3pm)				User Contributed Perl Documentation			       MboxParser::Mail::Body(3pm)

NAME
Mail::MboxParser::Mail::Body - rudimentary mail-body object SYNOPSIS
use Mail::MboxParser; [...] # $msg is a Mail::MboxParser::Mail my $body = $msg->body(0); # or preferably my $body = $msg->body($msg->find_body); for my $line ($body->signature) { print $line, " " } for my $url ($body->extract_urls(unique => 1)) { print $url->{url}, " "; print $url->{context}, " "; } DESCRIPTION
This class represents the body of an email-message. Since emails can have multiple MIME-parts and each of these parts has a body it is not always easy to say which part actually holds the text of the message (if there is any at all). Mail::MboxParser::Mail::find_body will help and suggest a part. METHODS
as_string ([strip_sig => 1]) Returns the textual representation of the body as one string. Decoding takes place when the mailbox has been opened using the decode => 'BODY' | 'ALL' option. If 'strip_sig' is set to a true value, the signature is stripped from the string. as_lines ([strip_sig => 1]) Sames as as_string() just that you get an array of lines with newlines attached to each line. NOTE: When the body is actually some encoded binary data (most commonly such a body is base64-encoded), you can still use this method. Then you wont really get proper lines. Instead you get chunks of binary data that you should concatenate as in my $binary = join "", $body->as_lines; If 'strip_sig' is set to a true value, the signature is stripped from the string. signature Returns the signature of a message as an array of lines. Trailing newlines are already removed. $body->error returns a string if no signature has been found. extract_urls extract_urls (unique => 1) Returns an array of hash-refs. Each hash-ref has two fields: 'url' and 'context' where context is the line in which the 'url' appeared. When calling it like $mail->extract_urls(unique => 1), duplicate URLs will be filtered out regardless of the 'context'. That's useful if you just want a list of all URLs that can be found in your mails. $body->error() will return a string if no URLs could be found within the body. quotes Returns a hash-ref of array-refs where the hash-keys are the several levels of quotation. Each array-element contains the paragraphs of this quotation-level as one string. Example: my $quotes = $msg->body($msg->find_body)->quotes; print $quotes->{1}->[0], " "; print $quotes->{0}->[0], " "; This should print the first paragraph of the mail-body that has been quoted once and below that the paragraph that supposedly is the reply to this paragraph. Perhaps thus: > I had been trying to work with the CGI module > but I didn't yet fully understand it. Ah, it is tricky. Have you read the CGI-FAQ that comes with the module? Mark that empty lines will not be ignored and are part of the lines contained in the array of $quotes->{0}. So below is a little code-snippet that should, in most cases, restore the first 5 paragraphs (containing quote-level 0 and 1) of an email: for (0 .. 4) { print $quotes->{0}->[$_]; print $quotes->{1}->[$_]; } Since quotes() considers an empty line between two quotes paragraphs as a paragraph in $quotes->{0}, the paragraphs with one quote and those with zero are balanced. That means: scalar @{$quotes->{0}} - DIFF == scalar @{$quotes->{1}} where DIFF is element of {-1, 0, 1}. Unfortunately, quotes() can up to now only deal with '>' as quotation-marks. VERSION
This is version 0.55. AUTHOR AND COPYRIGHT
Tassilo von Parseval <tassilo.von.parseval@rwth-aachen.de> Copyright (c) 2001-2005 Tassilo von Parseval. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl v5.12.3 2005-12-08 MboxParser::Mail::Body(3pm)
All times are GMT -4. The time now is 01:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy