Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


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

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-17-2013
Registered User
 
Join Date: Oct 2011
Location: Bucharest
Posts: 52
Thanks: 18
Thanked 4 Times in 4 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 01-17-2013
radoulov's Avatar
--
 
Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 5,468
Thanks: 139
Thanked 538 Times in 506 Posts

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

Sponsored Links
    #3  
Old 01-17-2013
Registered User
 
Join Date: Oct 2011
Location: Bucharest
Posts: 52
Thanks: 18
Thanked 4 Times in 4 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 "~"
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:30 AM.