need to remove invariant characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need to remove invariant characters
# 8  
Old 08-22-2012
Try this updated solution:

Code:
gawk '
{
   key[NR]=$1;
   for(i=1;i<length($2);i+=2) {
       site[i,NR]=substr($2,i,2)
       if(i>maxi)maxi=i
   }
}
END {
    c=0
    for(i=1;i<=maxi;i+=2) {
           v=""
           mismatch=0
           for(r=1;r<=NR;r++) {
              if(v=="" && !(site[i,r]~"-"))v=site[i,r];
              else if(length(v)&&site[i,r]!=v) {
                 if(++mismatch>1) {
                     keep[++c]=i;
                     r=NR
                 }
              }
           }
        }
        for(r=1;r<=NR;r++) {
           printf "%s ", key[r]
           for(i=1;i<=c;i++) printf "%s", site[keep[i],r]
           printf "\n"
        }
}' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove first 2 characters and last two characters of each line

here's what im trying to do. i have a file containing lines similar to this: data.txt: 1hsRmRsbHRiSFZNTTA1dlEyMWFkbU5wUW5CSlIyeDFTVU5SYjJOSFRuWmpia0ZuWXpKV2FHTnRU 1lKUnpWMldrZFZaMG95V25oYQpSelEyWTBka2QyRklhSHBrUjA1b1kwUkJkd3BOVXpWM1lVaG5k... (5 Replies)
Discussion started by: SkySmart
5 Replies

2. UNIX for Dummies Questions & Answers

How do I remove ^M characters with VI

I have a file with all kinds of ^M at the end of each line. How the heck can these be removed? I tried a global search and replace, but it doesn't seem to work. Thanks! (8 Replies)
Discussion started by: HmmBerger
8 Replies

3. Shell Programming and Scripting

Remove whitespaces in the n first characters?

I assume removing whitespaces in the n first characters of a string would be an easy task for sed? If so, how? (7 Replies)
Discussion started by: KidCactus
7 Replies

4. UNIX for Dummies Questions & Answers

How to Remove Special Characters

Dear Members, We have a file which contains some special characters. I need to replace these special character by a new line character(\n). The Special character is \x85. I am not sure what this character means and how we can remove it. Any inputs are greatly appreciated. Thanks... (5 Replies)
Discussion started by: sandeep_1105
5 Replies

5. Shell Programming and Scripting

Remove characters from file name

Here is my code. for file in *1.3.html ; do mv "$file" `echo $file | tr '.1.3' ''` ; done For some reason I am getting an error. mv: file.idlesince.1.3.html and file.idlesince.1.3.html are identical Could this be done a different way? (5 Replies)
Discussion started by: mrlayance
5 Replies

6. UNIX for Advanced & Expert Users

remove characters

hi i have a file with these strings: 123_abc_X1116990 how to get rid of 123_abc_ and keep only X1116990? I have columns of these: 123_abc_X1134640 123_dfg_X1100237 123_tyu_X1103112 123_tyui_X1116990 thx (5 Replies)
Discussion started by: melanie_pfefer
5 Replies

7. UNIX for Dummies Questions & Answers

How to remove Characters before '~'

Hi, I am having a file which contains records as follows: DETAIL_KEY~12344|ACTIVE_PASSIVE~Y|AVG_SIZE_OF_RESPONSE~123123131 DETAIL_KEY~12344|ACTIVE_PASSIVE~Y|AVG_SIZE_OF_RESPONSE~123123131 DETAIL_KEY~12344|ACTIVE_PASSIVE~Y|AVG_SIZE_OF_RESPONSE~123123131... (4 Replies)
Discussion started by: Amey Joshi
4 Replies

8. UNIX for Dummies Questions & Answers

Remove control characters

Hi, When I do a man and save it into a file, I end up getting a lot of control characters. How can I remove them?? I tried this: /1,$ s/^H//g But I get an error saying "no previous regular expression". Can someone help me with this. Thanks, Aravind (5 Replies)
Discussion started by: aravind_mg
5 Replies
Login or Register to Ask a Question
LPSINVELM(1)							   User Commands						      LPSINVELM(1)

NAME
lpsinvelm - check invariants and use these to simplify or eliminate summands of an LPS SYNOPSIS
lpsinvelm [OPTION]... --invfile=INVFILE [INFILE [OUTFILE]] DESCRIPTION
Checks whether the boolean formula (an mCRL2 data expression of sort Bool) provided as invariant is an invariant of the linear process specification (LPS) in INFILE. If this is the case, the tool eliminates all summands of the LPS whose condition violates the invariant, and writes the result to OUTFILE. If INFILE is present, stdin is used. If OUTFILE is not present, stdout is used. The tool can also be used to simplify the conditions of the summands of the given LPS. OPTIONS
OPTION can be any of the following: -y, --all-violations do not terminate as soon as a single violation of the invariant is found, but report all violations instead -c, --counter-example display a valuation indicating why the invariant could possibly be violated if it is uncertain whether a summand violates the invariant -o, --induction apply induction on lists -iINVFILE, --invariant=INVFILE use the boolean formula (an mCRL2 data expression of sort Bool) in INVFILE as invariant -n, --no-check do not check if the invariant holds before eliminating unreachable summands -e, --no-elimination do not eliminate or simplify summands, but add the invariant to each condition -pPREFIX, --print-dot=PREFIX save a .dot file of the resulting BDD if it is impossible to determine whether a summand violates the invariant; PREFIX will be used as prefix of the output files -rNAME, --rewriter=NAME use rewrite strategy NAME: 'jitty' for jitty rewriting (default), 'jittyc' for compiled jitty rewriting, 'jittyp' for jitty rewriting with prover -l, --simplify-all simplify the conditions of all summands, instead of just eliminating the summands whose conditions in conjunction with the invariant are contradictions -zSOLVER, --smt-solver=SOLVER use SOLVER to remove inconsistent paths from the internally used BDDs (by default, no path elimination is applied): 'cvc' for the SMT solver CVC3 -sNUM, --summand=NUM eliminate or simplify the summand with number NUM only -tLIMIT, --time-limit=LIMIT spend at most LIMIT seconds on proving a single formula --timings[=FILE] append timing measurements to FILE. Measurements are written to standard error if no FILE is provided Standard options: -q, --quiet do not display warning messages -v, --verbose display short intermediate messages -d, --debug display detailed intermediate messages --log-level=LEVEL display intermediate messages up to and including level -h, --help display help information --version display version information AUTHOR
Written by Luc Engelen. REPORTING BUGS
Report bugs at <http://www.mcrl2.org/issuetracker>. COPYRIGHT
Copyright (C) 2012 Technische Universiteit Eindhoven. This is free software. You may redistribute copies of it under the terms of the Boost Software License <http://www.boost.org/LICENSE_1_0.txt>. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
See also the manual at <http://www.mcrl2.org/mcrl2/wiki/index.php/User_manual/lpsinvelm>. lpsinvelm mCRL2 toolset 201202.0 (Release) April 2012 LPSINVELM(1)