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 and shell scripting languages 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 07:37 AM
Help, filtering some info. from a file under "()" varungupta UNIX for Advanced & Expert Users 10 09-11-2007 07:59 AM
[Urgent]how to print the file names into a txt file??? kumarsaravana_s Shell Programming and Scripting 15 03-12-2007 03:32 AM
Filtering multiple entries in a file suman_jakkula Shell Programming and Scripting 2 08-22-2006 06:02 AM
filtering by file size nir UNIX for Dummies Questions & Answers 2 01-17-2002 10:17 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 05-11-2006
HItesh HItesh is offline
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
  #2 (permalink)  
Old 05-11-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

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

See man pages of comm. See if it helps.
  #3 (permalink)  
Old 05-11-2006
HItesh HItesh is offline
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
  #4 (permalink)  
Old 05-11-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
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.
  #5 (permalink)  
Old 05-11-2006
HItesh HItesh is offline
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
  #6 (permalink)  
Old 05-11-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
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
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 08:08 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