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
compare files spt Shell Programming and Scripting 1 05-09-2008 11:57 AM
compare two files fredao Shell Programming and Scripting 17 01-31-2007 07:39 AM
Compare files Berserk Shell Programming and Scripting 6 09-05-2005 05:04 AM
compare files again ithomp Shell Programming and Scripting 2 06-17-2004 04:46 AM
help! need to compare files danielsf Shell Programming and Scripting 6 07-09-2003 06:09 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 09-19-2008
arkhei arkhei is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 14
How to compare to files

I have these two files:
file1
NPANXX|BILLDATE|DIVCODE|COMID|RAO|LIKECODE|BOSS|SORD|STATECODE|
087001|BP01|H|SWBT| |041|IMR6|IMSR6|AR|
087002|BP03|H|SWBT| |042|IMR6|IMSR6|AR|
087003|BP05|H|SWBT| |043|IMR6|IMSR6|AR|
...
file2
06300100009999OK
06300200009999OK

i want to extract the first six digits of the file2 then the extracted digits will be compared to file1 if match are found it will be extracted and they will be put in a new directory. Im planning to use cut but i dont know how.please help.
  #2 (permalink)  
Old 09-20-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,787
one way

Code:
cut -c1-6 file2 > t.sed
grep -f t.sed file1

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 03:21 PM.


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