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 can i add two numbers kripssmart UNIX for Dummies Questions & Answers 4 01-06-2009 06:45 PM
Numbers of records in SAS dataset sasaliasim Shell Programming and Scripting 2 04-21-2008 05:55 PM
need top 3 numbers shary Shell Programming and Scripting 4 03-25-2008 01:58 AM
How to add numbers? pnxi Shell Programming and Scripting 7 09-11-2003 07:25 AM
Add some numbers! TalkShowHost Shell Programming and Scripting 3 05-15-2002 01:28 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 11-25-2008
mk1216 mk1216 is offline
Registered User
  
 

Join Date: Sep 2008
Location: Bristol , United Kingdom
Posts: 38
for i in `cat numbers.dat`
do
cat data.dat|awk -F"," '{if($1==number) print $0}' number="$i"
done > newfile.dat
  #2 (permalink)  
Old 11-25-2008
mk1216 mk1216 is offline
Registered User
  
 

Join Date: Sep 2008
Location: Bristol , United Kingdom
Posts: 38
">" does the redirection
  #3 (permalink)  
Old 11-25-2008
Shiv@jad Shiv@jad is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 27
What if the record's first field is "Event:number" and i want to check only for number match (neglecting Event word) against number file.
  #4 (permalink)  
Old 11-25-2008
mk1216 mk1216 is offline
Registered User
  
 

Join Date: Sep 2008
Location: Bristol , United Kingdom
Posts: 38
for i in `cat numbers.dat`
do
cat data.dat|awk -F"," '{if($1~/number/) print $0}' number="$i"
done > newfile.dat

~/number/ tries to match(regular expression) content of first field in the record with value in "number" variable.
  #5 (permalink)  
Old 11-25-2008
Shiv@jad Shiv@jad is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 27
its giving me error
awk: The statement cannot be correctly parsed.
The source line is 1.
syntax error The source line is 1.
The error context is
>>> {if($1*~ <<<
  #6 (permalink)  
Old 11-25-2008
mk1216 mk1216 is offline
Registered User
  
 

Join Date: Sep 2008
Location: Bristol , United Kingdom
Posts: 38
for number in `cat numbers.dat`
do
cat data.dat|awk -F"," '{if($1~/'$number'/) print $0}'
done

1,3,4,
1m,h,j
h2,t,y
3,f,r
4,5,h


Is this the output you were looking for ?
  #7 (permalink)  
Old 11-25-2008
Shiv@jad Shiv@jad is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 27
Yes I am looking for this kind of output however the script is not segregating records for me.
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

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:10 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