• if-else in awk. Always confuses me...

    awk '{if ($14 == 4) print $0; else print "else"}' b/moviestate0000.dat
    
    awk '{if ($1 == "Time") printf("%s ",substr($3,0,11)); else if ($1 == "Average") printf("%s \n", $5)}' SY.log
    
    awk 'BEGIN {RS="\n    "} {print $1,$2,$3,$4,$5,$6}'
    
    
    awk 'BEGIN {getline < "tt.MB.dark.dat"; ttnum=(1.0*$1) ;line=$0} $1 == ttnum {print line, $2;getline< "tt.MB.dark.dat"; ttnum=(1.0*$1) ; line=$0}' numb.syn > tt.MB.dark.H.dta
    
    
    


  • command-line inputting for csh
    #
        if ($#argv < 1) then
            echo "Usage: $0 file [ file ... ]"
            exit 1
        endif
    #
    foreach file ($argv)
            echo -n $file': '
            @ nl = `wc $file | awk '{print $1}'`
            while ($nl > 0)
                echo -n '*'
                @ nl--
            end
            echo ''
        end
    #
    


  • SuperMongo: Making gray histograms in SM, and having them print right
    ctype = ctype() concat {14671839 12566463 10461087 8355711 6250335 4144959 2039583} # 223, 191, 159, 127, 95, 63, 31
    ctype = ctype(string) concat {gray1 gray2 gray3 gray4 gray5 gray6 gray7}
    


  • SuperMongo: macro to plot symbols (letters).
    
    macro dosym 3 {
    
    define num (0)
    foreach var $1 {
    echo $num $var
    define g ($1[$num])
    define h ($2[$num])
    relocate $g $h
    putlabel 5 $3
    define num ($num+1)
    }
    
    }
    


     sed -e 's/processcolors where/sub where/' -e 's/processcolors/2/' spin_3hr.ps  > blah.ps
    


  • IRAF: Batch mode for phot
    phot @Images.lis coords=@Coords.coo inter-
    


  • Basic (very ugly) loop in cshell with non-integers
    #!/bin/csh
    
    
    set ie = 3.5
    set inc = 0.1
    set go =  `echo " " | awk '{if ('$ie' < 10) print "1"; else print "0"}'`
    
    while ($go == 1) 
    echo $ie
    
    
    
    
    set ie = `echo " " | awk '{print '$ie'+'$inc'}'`
    set go =  `echo " " | awk '{if ('$ie' < 10) print "1"; else print "0"}'`
    end
    

  • In vi, getting rid of Ctrl-M in a text file from windows..
    :%s/(ctrl-V)(ctrl-M/\1\r/g
    


  • Gnuplot
    set term jpeg
    set output "plot.jpeg"
    


  • Perl:
    sub parse {
        my(@parsed);
        @parsed = split(/\s+/,$_[0]);
        chomp(@parsed);
      #remove whitespace at beginning of line, if any
        while ($parsed[0] eq "") {shift(@parsed)}
        return(@parsed);
    }