The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem in filtering the file adityam UNIX for Dummies Questions & Answers 0 11-22-2007 04:37 AM
Help, filtering some info. from a file under "()" varungupta UNIX for Advanced & Expert Users 10 09-11-2007 03:59 AM
[Urgent]how to print the file names into a txt file??? kumarsaravana_s Shell Programming and Scripting 15 03-12-2007 12:32 AM
Filtering multiple entries in a file suman_jakkula Shell Programming and Scripting 2 08-22-2006 02:02 AM
filtering by file size nir UNIX for Dummies Questions & Answers 2 01-17-2002 07:17 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-10-2006
Registered User
 

Join Date: May 2006
Posts: 3
Urgent: Filtering a File

Hi all

I need to write a small shell script, where we have one Log file and another File 1 containing some tags in it.

My log file can have multiple tags in it which can be other than the ones that are part of File 1.

So I need to write a script that will run and test whether the tags present in Log file are same as the ones that are in file 1

If there are some other tags in Log file other than file 1 then we need to make a file 2 containing all the new tags that are not present in File1.

Please help me in writing this script as it is very urgent

Regds,
Hitesh
Reply With Quote
Forum Sponsor
  #2  
Old 05-10-2006
Playing with Ubuntu Now!
 

Join Date: Oct 2005
Location: Chennai
Posts: 364
looked at comm?

See man pages of comm. See if it helps.
Reply With Quote
  #3  
Old 05-11-2006
Registered User
 

Join Date: May 2006
Posts: 3
Hey man can u please elaborate a bit more on it ...

i am new to this forum
Reply With Quote
  #4  
Old 05-11-2006
Playing with Ubuntu Now!
 

Join Date: Oct 2005
Location: Chennai
Posts: 364
example

Suppose file1 contains
1
2
3
4
5
6
7
and file2 contains
4
5
6
7
8
9
13
24
34
then

comm -12 prints lines common to two files.
comm -12 file1 file2
4
5
6
7

Check 'man comm'. Also remember comm works on sorted files.
Reply With Quote
  #5  
Old 05-11-2006
Registered User
 

Join Date: May 2006
Posts: 3
Hi

thats so gr8 of u that u hv helped me by writing an example but now i hv understood that comm will give u the comm tags /numbers in the 2 files ....

but if i look at this example itself what i need now is that i need to create a new file file 3 that will hv all the tags/ numbers that do not belong to file 2 but are part of file 1....

so my file 3 should be like
1
2
3


Please help me a bit on this ...

thanx in advance
Reply With Quote
  #6  
Old 05-11-2006
Playing with Ubuntu Now!
 

Join Date: Oct 2005
Location: Chennai
Posts: 364
check man.

Check manual. Its all there. by the way, for your question -
comm -23 file1 file2 --> will give you lines in file1 and not in file2. You can redirect this output to a new file as required.
comm -23 file1 file2 >file3
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:31 PM.


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

Content Relevant URLs by vBSEO 3.2.0