Sponsored Content
Top Forums UNIX for Dummies Questions & Answers SOLVED: Text file compare using perl Post 302446683 by suvenduperl on Thursday 19th of August 2010 10:32:15 AM
Old 08-19-2010
SOLVED: Text file compare using perl

I have two text file....
One text file contain in this format......
keyvalue.txt
Code:
\SUM\SUM_cam.c  
\SUM\SUM_cam.h  
\SUM\SUM_command.c  
\SUM\SUM_command.h  
\SUM\SUM_dab.c  
\SUM\SUM_dmb.c  
\SUM\SUM_eventHandler.h  
\SUM\SUM_eventHandler_dab.c  
\SUM\SUM_eventHandler_dmb.c  
\SUM\SUM_fap.c  
\SUM\SUM_fap.h  
\SUM\SUM_private.h  
\SUM\SUM_task_dab.c  
\SUM\SUM_task_dmb.c  
\SUM\Makefile  
\SUM\SUM_cam.c

second text file looks like this......
samplesource.txt
Code:
\SUM\SUM_cam.c@@\main\base2ucm_source\600_int\1
\NEW\NEW_calc.c@@\main\base2ucm_source\600_int\1
\NEW\NEW_FAP.c@@\main\base2ucm_source\600_dev_dmb\1
\SIN\COM\SIN_COMconnection.c@@\main\base2ucm_source\600_int\1
\SIN\COM\COMconnection.sm@@\main\base2ucm_source\600_int\1
\SIN\IN\SIN_INdevice.c@@\main\base2ucm_source\600_int\1
\SUM\SUM_cam.c@@\main\base2ucm_source\600_int\1

Now i want to compare each element of key.txt with samplesource.txt.

Ex:
\SUM\SUM_cam.c exist in samplesource.txt.
If it is found then put a (%) symbol before \SUM\SUM_cam.c in key.txt and
cut the element after second @ and put it in key.txt

Mean Now Key.txt should look like this:
Code:
%  \SUM\SUM_cam.c                      main\base2ucm_source\600_int\1
     \SUM\SUM_cam.h  
     \SUM\SUM_command.c  
     \SUM\SUM_command.h  
     \SUM\SUM_dab.c  
     \SUM\SUM_dmb.c  
     \SUM\SUM_eventHandler.h  
     \SUM\SUM_eventHandler_dab.c  
     \SUM\SUM_eventHandler_dmb.c  
     \SUM\SUM_fap.c  
     \SUM\SUM_fap.h  
     \SUM\SUM_private.h  
     \SUM\SUM_task_dab.c  
     \SUM\SUM_task_dmb.c  
     \SUM\Makefile  
     \SUM\SUM_cam.c

NOTE:
samplesource.txt may conatin \SUM\SUM_cam.c so many times.
But we should concentrate our search to the first occurance...........

Hope you got my point guys..................

Last edited by Yogesh Sawant; 08-27-2010 at 09:37 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File Compare in PERL

I need to look at a log file every half hour or so to make sure that some activity is going on there. I thought I would write a quick PERL script that would copy the current log file to the temp directory, compare it to the previous log file (from 30 minutes ago) and exit with an error status if... (1 Reply)
Discussion started by: Cbish68
1 Replies

2. Shell Programming and Scripting

SOLVED: reading config file in a perl script

Hi! I have a need to do this in Perl. script.pl -config file The script would be doing a wget/LWP on a URL which is defined in the config file. So when I run the script it should return either one of these conditions - 1) OK with exit status 0. Should also print "wget URL" 2)... (6 Replies)
Discussion started by: jacki
6 Replies

3. Shell Programming and Scripting

[Solved] perl and grep: get a script to look at more then one file

hi guys i have this very messy script, that looks in /var/log/messages.all for an error and reports if it finds the key works how can i get it to look at more then one file, i.e /var/log/message.all * so it looks in old logs as well thanks exit 0 if (isRenderNode(hostname)); my... (4 Replies)
Discussion started by: ab52
4 Replies

4. Shell Programming and Scripting

[Solved] I need help with a text file.

Hello everyone, I need to write a shell script for a file consisting of 3 columns, first column is frequency the second one is power and the last one is number of occurence. I basically need to get the power and the frequency corresponding to the highest number of occurrence number. Below is the... (6 Replies)
Discussion started by: johankor
6 Replies

5. Shell Programming and Scripting

[Solved] Formatting the text file

Hi All, I ahve requirement where I want to put the text file in into proper format. I am wondering how can i achieve that:- Host/Alias Name IP Address Resolved sinuiy01.infra.go2uti.com 10.240.8.158 N sinuid20.devtst.go2uti.com 10.240.8.230 N sinuid21.devtst.go2uti.com... (6 Replies)
Discussion started by: sharsour
6 Replies

6. Shell Programming and Scripting

[Solved] How to print specific text from a file?

Hi All, I have the below text file from which I have to cut particular section starting from PTR_Security_Rpeorting.cpf to PTR_Security_Reporting_Env93_export. Report Model............: "D:\Cognos_Publishing\tmp.a2R94KLQec"\PTR_Security_Reporting.cpf Report Output Script....:... (4 Replies)
Discussion started by: Vikram_Tanwar12
4 Replies

7. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

8. Shell Programming and Scripting

[Solved] Replacing line of text while file is closed

Is it possible to replace a line of text within a file while it's closed with a single command or a script? Please show me an example or point me to a webpage that shows an example. The file has this line of text: LoginGraceTime 100 I want to replace it with the following: ... (2 Replies)
Discussion started by: wdg74
2 Replies

9. Shell Programming and Scripting

[Solved] awk compare two different columns of two files and print all from both file

Hi, I want to compare two columns from file1 with another two column of file2 and print matched and unmatched column like this File1 1 rs1 abc 3 rs4 xyz 1 rs3 stu File2 1 kkk rs1 AA 10 1 aaa rs2 DD 20 1 ccc ... (2 Replies)
Discussion started by: justinjj
2 Replies

10. Shell Programming and Scripting

[Solved] My script executes poorly as a text file.

Hello again, I have put together a shell script using sed and some shell commands, and it runs pretty well when I am in terminal, but when I save it as a text file and invoke it through the terminal by typing its path, all I get are errors. Can some one give me some hints as to what I am doing... (13 Replies)
Discussion started by: Paul Walker
13 Replies
h5jam(1)						      General Commands Manual							  h5jam(1)

NAME
h5jam - Add a user block to a HDF5 file SYNOPSIS
h5jam -u user_block -i in_file.h5 [-o out_file.h5] [--clobber] DESCRIPTION
h5jam concatenates a user_block file and an HDF5 file to create an HDF5 file with a user block. The user block can be either binary or text. The output file is padded so that the HDF5 header begins on byte 512, 1024, etc.. (See the HDF5 File Format.) If out_file.h5 is given, a new file is created with the user_block followed by the contents of in_file.h5. In this case, infile.h5 is unchanged. If out_file.h5 is not specified, the user_block is added to in_file.h5. If in_file.h5 already has a user block, the contents of user_block will be added to the end of the existing user block, and the file shifted to the next boundary. If --clobber is set, any existing user block will be overwritten. EXAMPLE USAGE
Create new file, newfile.h5, with the text in file mytext.txt as the user block for the HDF5 file file.h5. h5jam -u mytext.txt -i file.h5 -o newfile.h5 Add text in file mytext.txt to front of HDF5 dataset, file.h5. h5jam -u mytext.txt -i file.h5 Overwrite the user block (if any) in file.h5 with the contents of mytext.txt. h5jam -u mytext.txt -i file.h5 --clobber RETURN VALUE
h5jam returns the size of the output file, or -1 if an error occurs. CAVEATS
This tool copies all the data (sequentially) in the file(s) to new offsets. For a large file, this copy will take a long time. The most efficient way to create a user block is to create the file with a user block (see H5Pset_user_block), and write the user block data into that space from a program. The user block is completely opaque to the HDF5 library and to the h5jam and h5unjam tools. The user block is simply read or written as a string of bytes, which could be text or any kind of binary data. It is up to the user to know what the contents of the user block means and how to process it. When the user block is extracted, all the data is written to the output, including any padding or unwritten data. This tool moves the HDF5 file through byte copies, i.e., it does not read or interpret the HDF5 objects. SEE ALSO
h5dump(1), h5ls(1), h5diff(1), h5import(1), gif2h5(1), h52gif(1), h5perf(1), h5unjam(1). h5jam(1)
All times are GMT -4. The time now is 04:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy