Urgent: Filtering a File


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Urgent: Filtering a File
# 1  
Old 05-11-2006
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 Smilie

Regds,
Hitesh
# 2  
Old 05-11-2006
looked at comm?

See man pages of comm. See if it helps.
# 3  
Old 05-11-2006
Hey man can u please elaborate a bit more on it ...

i am new to this forum Smilie
# 4  
Old 05-11-2006
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  
Old 05-11-2006
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  
Old 05-11-2006
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with filtering records in a file

Hi, I have following records in a file more file1.txt setting applicaction ABC for user setting applicaction CDE for user setting applicaction XXX for user logging applicaction XXX for user I need to filter out records which have strings " setting... (5 Replies)
Discussion started by: manid
5 Replies

2. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

3. Shell Programming and Scripting

Filtering first file columns based on second file column

Hi friends, I have one file like below. (.csv type) SNo,data1,data2 1,1,2 2,2,3 3,3,2 and another file like below. Exclude data1 where Exclude should be treated as column name in file2. I want the output shown below. SNo,data2 1,2 2,3 3,2 Where my data1 column got removed from... (2 Replies)
Discussion started by: ks_reddy
2 Replies

4. UNIX for Dummies Questions & Answers

Filtering records from 1 file based on some manipulation doen on second file

Hi, I am looking for an awk script which should help me to meet the following requirement: File1 has records in following format INF: FAILEd RECORD AB1234 INF: FAILEd RECORD PQ1145 INF: FAILEd RECORD AB3215 INF: FAILEd RECORD AB6114 ............................ (2 Replies)
Discussion started by: mintu41
2 Replies

5. Shell Programming and Scripting

[ask]filtering file to indexing...

dear all, i have file with format like this file_master.txt 20110212|231213|rio|apri|23112|222222 20110212|312311|jaka|dino|31223|543234 20110301|343322|alfan|budi|32131|333311 ... i want filter with output like this index_nm.txt rio|apri jaka|dino ... index_years.txt 20110212... (7 Replies)
Discussion started by: zvtral
7 Replies

6. Shell Programming and Scripting

filtering the log file

Hi i have a log file like example below. I need only one field from below log all other need to be truncated from the log file. 2011-06-13 15:10:53,498 INFO ext.SP->CAL (log point 5) can any body help on this please. Thanks (4 Replies)
Discussion started by: mostwantedkisss
4 Replies

7. UNIX for Dummies Questions & Answers

Filtering a file

I have a list of directories looking something like; /usr/local/1/in /usr/local/1/out /usr/local/1/archive /usr/local/2/in /usr/local/2/out /usr/local/2/archive /usr/local/3/in /usr/local/3/out /usr/local/3/archive Is there a way I can filter the out and archive directories so I... (5 Replies)
Discussion started by: JayC89
5 Replies

8. UNIX for Dummies Questions & Answers

Filtering Log file

Hi, Iam trying to filter a log file in the below format |fffff|hhhhh|ffff|dd|mm|yy|hh|min||dd|mm|yy|hh|min the first set of |dd|mm|yy|hh|min is when the application ran the second set of |dd|mm|yy|hh|min when it ended. I will be removing the last of the months in the log file to... (1 Reply)
Discussion started by: baanprog
1 Replies

9. UNIX for Dummies Questions & Answers

problem in filtering the file

-------------------------------------------------------------------------------- Hi, Plz help me out with this. I have some requirement like this..... I have a file like this... * CS sent email (11.20) CALYPSO 1031276 9076673 CDSHY FAILED Nov 19 2007 7:28AM OASYS: Unable to find CUSTOMER... (0 Replies)
Discussion started by: adityam
0 Replies

10. UNIX for Dummies Questions & Answers

filtering by file size

Hi ! I wanted to know how can i filter files by "size range". like : getting all the files that are bigger than 100 byte and smaller than 200 byte ? I want to make it as a script... I noticed the unix command : find . -size +100c but i also want limit it's upper bounds. so something... (2 Replies)
Discussion started by: nir
2 Replies
Login or Register to Ask a Question