file_list=`ls $DATA_PATH | awk -F"_" 'NF==5" /> AWK syntax question - The UNIX and Linux Forums
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
egrep syntax question DKNUCKLES Shell Programming and Scripting 1 11-18-2007 04:46 PM
Simple Awk Question: If Syntax natdeamer Shell Programming and Scripting 1 09-10-2007 01:53 PM
yet another awk field syntax question prkfriryce Shell Programming and Scripting 4 03-22-2007 01:13 PM
C-shell: variable syntax question alex_5161 SUN Solaris 0 01-30-2007 02:43 PM
awk syntax question hcclnoodles Shell Programming and Scripting 2 10-28-2004 01:45 PM

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 10-27-2008
Leo_NN Leo_NN is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 34
AWK syntax question

Hi,

Have to check file names in some given directory.

SO, What is the right syntax here:
Quote:

>object_list="CUSTOMER ADDRESS TELEPHONE"
>file_list=`ls $DATA_PATH | awk -F"_" 'NF==5 && $1=="'$vendor'" && $2=="'$source'" && *$3*=="'$object_list'" {print $0}'`
*$3*=="'$object_list'" - just wanted to check if $3 is in the object_list.

And also, Do I need so many quotes around?
  #2 (permalink)  
Old 10-28-2008
redoubtable redoubtable is offline
Registered User
  
 

Join Date: Aug 2008
Location: Portugal
Posts: 242
why are you using * around $3 ?

The syntax is correct if you remove the * like

Code:
file_list=`ls $DATA_PATH | awk -F"_" 'NF==5 && $1=="'$vendor'" && $2=="'$source'" && $3=="'$object_list'" {print $0}'`

  #3 (permalink)  
Old 10-28-2008
Leo_NN Leo_NN is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 34
object_list="CUSTOMER ADDRESS TELEPHONE"

Here I wanted to check if $3 is in the object_list, not equal, but part of it.
For instance if $3="CUSTOMER" - OK.
So I need something like IN or *$3* syntax, I think.

thanks.
  #4 (permalink)  
Old 10-28-2008
shruthinagaraj shruthinagaraj is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
Please can u tell me how to post a new thread? i am new user here, i am not finding any link to do so! please help me...
  #5 (permalink)  
Old 10-28-2008
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
To the OP: use ~ for contains rather than == (use nawk / /usr/xpg4/bin/awk on solaris)

To the thread hijacker ;-) , shruthinagaraj, go to a particular forum where you wish to post - in the top left is a "start new thread" button...
  #6 (permalink)  
Old 10-28-2008
Leo_NN Leo_NN is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 34
Is it ok to do it that way:

I can't do:
Quote:
awk '... $object_list ~ $3 ...'
But I can
Quote:
awk '... $3~$object_list...'
for some reasons?
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 02:15 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