Print lines that match regex on xth string | Unix Linux Forums | Shell Programming and Scripting

  Unix/Linux Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Print lines that match regex on xth string

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-17-2013
black_fender black_fender is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 27 February 2015, 7:11 AM EST
Location: Bucharest
Posts: 69
Thanks: 22
Thanked 5 Times in 5 Posts
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.
Sponsored Links
    #2  
Old Unix and Linux 01-17-2013
radoulov's Unix or Linux Image
radoulov radoulov is offline Forum Staff  
Moderator
 
Join Date: Jan 2007
Last Activity: 4 March 2015, 10:06 AM EST
Location: Варна, България / Milano, Italia
Posts: 5,689
Thanks: 184
Thanked 623 Times in 581 Posts

Code:
awk -F"|" '$22 ~ /20130117090000/' ...

Sponsored Links
    #3  
Old Unix and Linux 01-17-2013
black_fender black_fender is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 27 February 2015, 7:11 AM EST
Location: Bucharest
Posts: 69
Thanks: 22
Thanked 5 Times in 5 Posts
Quote:
Originally Posted by radoulov View Post
Code:
awk -F"|" '$22 ~ /20130117090000/' ...

Hello, thank you, yes this was what I was looking for. Didn't think to use "~" Unix or Linux Image
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
perl regex string match issue..kindly help avskrm Shell Programming and Scripting 5 10-04-2012 09:35 AM
print first few lines, then apply regex on a specific column to print results. kchinnam Shell Programming and Scripting 4 08-24-2010 04:24 PM
awk to print lines based on string match on another line and condition rowie718 Shell Programming and Scripting 5 06-14-2010 05:36 PM
exact string match ; search and print match bash_in_my_head Shell Programming and Scripting 8 05-23-2010 12:41 AM
Regex to match when input is not a certain string (can't use grep -v) kdelok UNIX for Dummies Questions & Answers 1 02-03-2010 04:45 PM



All times are GMT -4. The time now is 05:00 AM.