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

  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 Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-17-2013
black_fender black_fender is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 1 September 2014, 4:01 AM EDT
Location: Bucharest
Posts: 66
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 01-17-2013
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
Moderator
 
Join Date: Jan 2007
Last Activity: 23 October 2014, 8:02 AM EDT
Location: Варна, България / Milano, Italia
Posts: 5,675
Thanks: 184
Thanked 620 Times in 578 Posts

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

Sponsored Links
    #3  
Old 01-17-2013
black_fender black_fender is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 1 September 2014, 4:01 AM EDT
Location: Bucharest
Posts: 66
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 "~"
Sponsored Links
Closed Thread

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 09:46 AM.