Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    47
    Rep Power
    23
    Code:
    dos2unix newfile
    dos2unix oldfile
    This will permanently remove ^M characters from file and then execute the awk code.
  2. #17
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    9
    Rep Power
    0

    Thumbs up


    But ofcourse.... yes, that seemed to work... I checked the newfile for ^M characters and I didn't see any. So I thought it is the print $0 command that is inserting it, but I was wrong.

    Thank you for your help, you've been really patient and helpful. I learned a whole lot about awk from this one program. It was very helpful. :-)
  4. #18
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Hi!


    I have a problem with a program in awk. I want to compare two text files. If there are same words in both, I would like to know which words I how many.
    I try diferent ways but doesn't work. Just compare in the first file. Could someone help me.

    awk '
    FILENAME==definicion{def[$2]++;next}
    FILENAME==vocabulario{voc[$3]++;next}
    {
    for(i=1;i<=NR;i++)
    def[tolower($i)]++
    for(j=1;j<=NR;j++)
    voc[tolower($j)]++
    }
    END{#
    contador=0;
    for(i in def){#for def
    for(j in voc){#for voc
    if(def[i]== voc[j]){#if
    contador++
    print i " = " j
    }# end if
    }#end voc
    }#end def
    print "El contador es:" contador

    }' definicion=$2 vocabulario=$3 $*



    awk '
    FILENAME==definicion{def[$2]++;next}
    FILENAME==vocabulario{voc[$3]++;next}
    {
    for(i=1;i<=NR;i++){
    if( ($i in def)&&($i in voc) ){
    print substr($i,1,length($i)-2) " "
    }#if
    }#for
    print "no equals " i
    }' definicion=$2 vocabulario=$3 $*
  6. #19
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Please?


    [QUOTE=tete0408]I have a problem with a program in awk. I want to compare two text files. If there are same words in both, I would like to know which words & how many.
    I try diferent ways but doesn't work. Just compare in the first file. Could someone help me PLEASE?.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo