The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to access values of awk/nawk variables outside the awk/nawk block? saniya Shell Programming and Scripting 5 05-13-2008 04:37 AM
nawk & awk sd12 UNIX for Advanced & Expert Users 5 05-05-2008 07:46 AM
nawk/ksh help DeltaX Shell Programming and Scripting 0 03-06-2008 11:54 AM
nawk -v to awk kamel.seg Shell Programming and Scripting 2 12-18-2007 03:30 AM
nawk whatisthis Shell Programming and Scripting 3 09-29-2004 10:44 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-28-2005
Registered User
 

Join Date: Jun 2005
Location: Alexandria, Scotland
Posts: 46
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
help with Awk or nawk

Can anyone explain to me why the first line doesn't work and the second seems to work fine. I am trying to find all occurances of text within a certain column (col 13) that start with the character V, I suppose it sounds simple but I have tried using the following but don't really understand what the periods are actually doing.

So the first line doesn't work yet the second does seem to...whats the difference...in laymans terms please

awk '{if ($13 ~ ".*V.") print}' text.file > newtext.file

awk '{if ($13 ~ ".*V.*..") print}' text.file

head text.file

SG99891970 G405H 25/10/05 29/10/05 C8 11 10 27/12/74 2712742214 31620 AB42 3JD VW01A
SG99926485 G405H 10/11/05 12/11/05 A1 36 10 01/11/80 0111802040 31620 AB42 5WA VW10
SG03130444 G405H 17/07/05 24/07/05 A1 36 10 18/09/27 blank 99995 CA11 7UF VW17
SG03130444 G405H 24/07/05 11/08/05 A1 18 43 18/09/27 blank 99995 CA11 7UF VW17
SG03144116 G405H 12/11/05 14/11/05 A1 36 10 10/05/84 blank 99961 DD3 0NH SW06
SG03128794 G405H 05/10/05 07/10/05 C8 11 10 22/07/53 blank 18343 DG1 1TQ VWD

Last edited by Gerry405; 11-28-2005 at 09:11 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-28-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,983
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
well.... they BOTH work just fine under Sun's 'nawk'.

Quote:
Originally Posted by Gerry405
I am trying to find all occurances of text within a certain column (col 13) that start with the character V
Based on the definition above:
Code:
nawk '$13 ~ /^V.*/' text.file
Reply With Quote
  #3 (permalink)  
Old 11-28-2005
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 627
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
since you're really only looking for the first letter in the column, you could also try ...
Code:
awk '$13 ~ /^V/' text.file
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
421 service not available, remote server has closed connection ^m automate ftp autosys awk trim bash eval bash exec bash for loop close_wait command copy/move folder in unix couldn't set locale correctly curses.h cut command in unix dead.letter find grep find null character in a unix file grep multiple lines grep or grep recursive inaddr_any inappropriate ioctl for device ksh if logrotate.conf lynx javascript mailx attachment mget mtime ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp script snoop unix stale nfs file handle syn_sent tar exclude test: argument expected unix unix .profile unix forum unix forums unix internals unix interview questions unix mtime unix simulator unix.com vi substitute vi+substitute+end+of+line+character while loop within while loop shell script


All times are GMT -7. The time now is 07:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101