The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
doubt in awk jisha Shell Programming and Scripting 4 04-16-2008 04:02 AM
AWK doubt Rafael.Buria Shell Programming and Scripting 2 02-06-2008 11:00 AM
SDL doubt royalibrahim High Level Programming 0 11-22-2007 01:49 AM
awk doubt.. esham Shell Programming and Scripting 11 10-11-2007 02:24 AM
ftp doubt ranj@chn Shell Programming and Scripting 0 01-04-2006 08:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-10-2008
soujanya_srk soujanya_srk is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 14
doubt about awk

i have a file like this:

awk.lst

smith : sales : 1200 : 2
jones:it:25000 : 2
roger : it : 1500 : 2
ravi | acct | 15000

i have 3 doubts

1)
when i say
awk -F ":" '$2 ~ /'it'/ {print $0}' awk.lst

i am not able to get jones in the ouput , is it because of space issue?

2)how to print all the second column values starting with s?

3) how to handle multiple record delimiters?

example, i want to take into account both ":" and also "|" in my
selections?

i mean awk -F ":" "|" is not working
  #2 (permalink)  
Old 01-10-2008
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
I tend to use nawk if there is more than one field delimiter like:

nawk -F"[:|]" '{if ( $2 ~ "it" ){print}}' awk.lst

not sure if all flavours of awk like the multiple delimiter syntax....
  #3 (permalink)  
Old 01-10-2008
gus2000 gus2000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 157
All editions of awk should support the use of a regex as the field delimiter. The above data file probably needs something like this:
Code:
awk -F ' *[:|] *' ....
Which is:

- any number of spaces (including none), followed by
- a single character, either a : or a |, followed by
- any number of spaces (including none)

Comprende?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0