Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and 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: 28 July 2015, 7:48 AM EDT
Location: Bucharest
Posts: 74
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: 23 April 2015, 3:05 PM EDT
Location: Варна, България / Milano, Italia
Posts: 5,690
Thanks: 184
Thanked 626 Times in 584 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: 28 July 2015, 7:48 AM EDT
Location: Bucharest
Posts: 74
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 "~" Linux
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 08: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 03:24 PM
awk to print lines based on string match on another line and condition rowie718 Shell Programming and Scripting 5 06-14-2010 04:36 PM
exact string match ; search and print match bash_in_my_head Shell Programming and Scripting 8 05-22-2010 11:41 PM
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 03:45 PM



All times are GMT -4. The time now is 11:04 PM.