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
QwtTextLabel(3) 						 Qwt User's Guide						   QwtTextLabel(3)

NAME
QwtTextLabel - A Widget which displays a QwtText. SYNOPSIS
#include <qwt_text_label.h> Inherited by QwtLegendItem. Public Slots void clear () void setText (const QString &, QwtText::TextFormat textFormat=QwtText::AutoText) virtual void setText (const QwtText &) Public Member Functions virtual int heightForWidth (int) const int indent () const int margin () const virtual QSize minimumSizeHint () const QwtTextLabel (const QwtText &, QWidget *parent=NULL) QwtTextLabel (QWidget *parent=NULL) void setIndent (int) void setMargin (int) virtual QSize sizeHint () const const QwtText & text () const QRect textRect () const virtual ~QwtTextLabel () Protected Member Functions virtual void drawContents (QPainter *) virtual void drawText (QPainter *, const QRect &) virtual void paintEvent (QPaintEvent *e) Detailed Description A Widget which displays a QwtText. Constructor &; Destructor Documentation QwtTextLabel::QwtTextLabel (QWidget *parent = NULL) [explicit] Constructs an empty label. Parameters: parent Parent widget QwtTextLabel::QwtTextLabel (const QwtText &text, QWidget *parent = NULL) [explicit] Constructs a label that displays the text, text Parameters: parent Parent widget text Text QwtTextLabel::~QwtTextLabel () [virtual] Destructor. Member Function Documentation void QwtTextLabel::clear () [slot] Clear the text and all QwtText attributes. void QwtTextLabel::drawContents (QPainter *painter) [protected, virtual] Redraw the text and focus indicator. void QwtTextLabel::drawText (QPainter *painter, const QRect &textRect) [protected, virtual] Redraw the text. Reimplemented in QwtLegendItem. int QwtTextLabel::heightForWidth (intwidth) const [virtual] Returns the preferred height for this widget, given the width. Parameters: width Width int QwtTextLabel::indent () const Return label's text indent in pixels. int QwtTextLabel::margin () const Return label's text indent in pixels. QSize QwtTextLabel::minimumSizeHint () const [virtual] Return a minimum size hint. void QwtTextLabel::paintEvent (QPaintEvent *event) [protected, virtual] Qt paint event Parameters: event Paint event Reimplemented in QwtLegendItem. void QwtTextLabel::setIndent (intindent) Set label's text indent in pixels Parameters: indent Indentation in pixels void QwtTextLabel::setMargin (intmargin) Set label's margin in pixels Parameters: margin Margin in pixels void QwtTextLabel::setText (const QwtText &text) [virtual, slot] Change the label's text Parameters: text New text Reimplemented in QwtLegendItem. void QwtTextLabel::setText (const QString &text, QwtText::TextFormattextFormat = QwtText::AutoText) [slot] Change the label's text, keeping all other QwtText attributes Parameters: text New text textFormat Format of text See also: QwtText QSize QwtTextLabel::sizeHint () const [virtual] Return label's margin in pixels. Reimplemented in QwtLegendItem. const QwtText & QwtTextLabel::text () const Return the text. QRect QwtTextLabel::textRect () const Calculate the rect for the text in widget coordinates Returns: Text rect Author Generated automatically by Doxygen for Qwt User's Guide from the source code. Version 5.2.2 Mon Aug 1 2011 QwtTextLabel(3)
All times are GMT -4. The time now is 03:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy