I am really apologized for this inconvenience. But thank you very much for your help.

Exactly this is what I want with little addition:

File with minimum energy 1 10 20 30 40 2 20 30 45 50 Another file 1 10 11 50 50 2 20 21 60 60 I want: R 11 100 30 R 21 120 5 30 = (50 + 50) - (30 + 40) 5 = (60 + 60) - (45 + 50) Where 100 = 50 + 50 120 = 60 + 60 .

I further explain in detail.

The below code which I have already posted (I am posting again)is giving me an output file with Bond Length R, Delocalization Range and Sum of EDRA and EDRB ($4+$5).

use strict; # Find the lowest-energy geometry # Prepare array EDRvars0 containg the EDR at each u from that geometrr +y open(F,">results.txt"); print F "# Bond_length Delocalization_length EDR \n"; # Loop over all log files foreach my $f (<*log>){ my $c=`grep -c "Normal term" $f`; chomp($c); # Avoid files that do +dn't converge if($c>0){ # Find the bond length. We assume this is built into the file +name my $R = $f; $R=~s/.log//; $R=~s/.*_//; # Find the U valnes my $Ustr = `grep -A37 "EDR alpha" $f | tail -n35|awk "{print \ +\\$3}"`; my @Uvars = split(/\n/,$Ustr); # Convert them into an array my $NU = scalar(@Uvars); # That array has $NU elements # Find the <EDR(u)> and sum alpha and beta my $EDRstr = `grep -A37 "EDR alpha" $f | tail -n35|awk "{print + \\\$4+\\\$5}"`; my @EDRvars = split(/\n/,$EDRstr); # Print the outputs foreach my $i(0..$NU-1){ print F sprintf("%8.3E %12.6E %12.6E\n",$R,$Uvars[$i],$EDR +vars[$i]); } } } close(F);

The out put is like this:

 R        U        EDR(that is EDRA+EDRB)

Now in this output I want to add another column Delta EDR that gives me the difference in ERD of any file and EDR of lowest energy file. Like:

 R        U          EDR(that is EDRA+EDRB)       Delta EDR (That is {(<EDRA>+<EDRB>)each file}-{(<EDRA>+<EDRB>)file with minimum energy})

Mean I want to edit the above code in such a way that it give me fifth column in out put containing the {(<EDRA>+<EDRB>)each file}-{(<EDRA>+<EDRB>)file with minimum energy}).

I am waiting your kind reply.


In reply to Re^6: Making commond for large number of files by acrobat118
in thread Making commond for large number of files by acrobat118

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.