Backup some shell Script

#!/bin/bash
# 0:stdin  1:stdout  2:stderr 3..9:files like below
while read a<&3 && read b<&4
do
    echo $a $b
    printf "0x%04d\n" $(echo "obase=16;$((a|b))" | bc) #obase is hexadecimal
done 3<a.txt 4<b.txt
#*****************************************************#
#!/bin/bash
shelldir=`dirname $0`
echo $shelldir
for fa in $(find -type f -name "a.txt")
do
    echo $fa
    echo ${fa%/*}  ## get the path of $fa
    fb="${fa%/*}/b.txt"
    echo $fb
    [ ! -f "$fb" ] && continue
    fc="${fa%/*}/c.txt"
    while read a<&3 && read b<&4
    do
        printf "0x%04d\n" $(echo "obase=16;$((a|b))" | bc)
    done 3<$fa 4<$fb >$fc
done
#***********************************************************
#!bin/bash
export PRJROOT=""
cd $PRJROOT
pwd
#***********************************************************
#!/bin/bash
# color
for i in `seq 30 37`;do
    echo -e "\x1b\x5b0;$i;1m $i;1m"
done
for j in `seq 40 47`;do
    for i in `seq 30 37`;do
        echo -e "\x1b\x5b0;$i;"$j"m $i;"$j"m"
    done
done
#*********************************************************
#!/bin/sh
CSVFILE='csv.txt'
TD_STR=''
#this function create a <td> block
create_td()

    #echo $1
    TD_STR=`echo $1 | awk 'BEGIN{FS=","}{i=1; while(i<=NF) {print "<td>"$i"</td>";i++}}'`
}
#this function create a row html script(<tr>block).
create_tr()

    create_td "$1"
    echo -e "<tr>\n$TD_STR\n<tr/>\n"
}
#create html script head
create_html_head()

    echo -e "<html>\n<body>\n<h1>$CSVFILE</h1>\n"
}
#create html script end
create_html_end()
{
    echo -e "</body></html>"
}
create_table_head()
{
    echo -e "<table border="1">\n"
}
create_table_end()
{
    echo -e "    \n"
}
create_html_head
create_table_head
while read LINE
do
    # echo "$LINE"
    create_tr "$LINE"
done < $CSVFILE
create_table_end
create_html_end
#****************************************************
#!/bin/bash 
MAX=`for i in $(cat maxMin.txt);do echo $i;done|sort -nr|head -1` 
MIN=`for i in $(cat maxMin.txt);do echo $i;done|sort -nr|tail -1` 
echo "the Max number is : $MAX" 
echo "the Min number is : $MIN"
#*****************************************************
#!/bin/sh
echo "Begin:"
sed -i -e 's/;/;\n/g' -e 's/{/\n{\n/g' -e 's/}/\n}\n/g' -e 's/\(\w\):/\1:\n/g' -e 's/\s\s*int\s/\nint /g' -e 's/>#/>\n#/g' -e 's/>using/>\nusing/g' -e 's/\s\s*:/ :/g' $1
sed -i -e '/^\s*$/'d $1
echo "vim:"$1
vim $1 <<end >&/dev/null
:%s/\(for.*;\)\n/\1/
:%s/\(for.*;\)\n/\1/
:%s/\s\s*/ /
:%s/\n\s*{\s*\n\s*}/{}/
:%s/)\s*{/){/
:%s/,\n\s*/, /
:%s/;\s*/; /
:%s!^\s*//.\{-}\s\{1,}\(\w\w\)!\1!
:%s!\s*//.*!!
:%s/^\s*\.*//
:%s/}\n;/};/
:g/^\s*$/d
ggVG=
:wq
end
echo "vim Done"
echo "g++:"
echo "..."
myName=`echo $1|sed 's/\.cc//'`
g++ $1 -o $myName
echo "Done"
#*****************************************************
#!/bin/bash -
if [ $# -ne 3 ];then
    echo "Usage : sh $0 <lane dir> <fadir>"
    exit
fi
Lanedir=$1
fadir=$2
chrlen=$3
len=($(awk '{print $2}' $chrlen))
chrN=24
i=1
while(($i <= $chrN))
do
    N=$(printf "%02d" "$i")
    if [ ! -d "chr$N" ];then
        mkdir "chr$N"
    fi
    echo "${len[$i-1]} $N chr$N " >chr$N/$N.sh
    i=$(($i+1))
done
#************************************************************
#!/bin/bash -
dir=`pwd`
fadirfa.cut
cd $dir
for i in chr*;
do
    N=$(expr $i : 'chr\([0-9][0-9]\)')
    if [ $N ];then
        echo "$N"
    fi
done
#**************************************************************
#!/bin/bash -
echo "--- Start Time : `date` ---"
for i in {1..9}
do
    cd chr0$i
    qsub $i.sh
    cd -
done
for i in {10..24}
do
    cd chr$i
    qsub $i.sh
    cd -
done
echo "--- End Time : `date` ---"
#**************************************************************
#!/bin/bash -
dir1=A-B
dir2=B-A
echo "--- Start Time : `date` ---"
out1=$dir1.simulated.out
out2=$dir2.simulated.out
grep simulated $dir1/*/*.hka >$out1
grep simulated $dir2/*/*.hka >$out2
awk -F: '{print $1$3}' $out1 |sed -e 's/\s*of.*//g' -e 's/^\s*//g' -e 's/\s*<\s*/\t/g' -e 's/\s\s*/\t/g' >$out1.clean
awk -F: '{print $1$3}' $out2 |sed -e 's/\s*of.*//g' -e 's/^\s*//g' -e 's/\s*<\s*/\t/g' -e 's/\s\s*/\t/g' >$out2.clean
NR1=`awk 'END{print NR}' $out1`
NR2=`awk 'END{print NR}' $out2`
pos1=`echo "scale=2;$NR1*0.05"|bc |sed  's/\..*//g'`
pos2=`echo "scale=2;$NR2*0.05"|bc |sed  's/\..*//g'`
if [ $pos1 -eq 0 ];then
    pos1=1
fi
if [ $pos2 -eq 0 ];then
    pos2=1
fi
sort -rn -k3 $out1.clean >$out1.sort
sort -rn -k3 $out2.clean >$out2.sort
cutoff1=`sed -n "$pos1"p $out1.sort|awk '{print $3}'`
cutoff2=`sed -n "$pos2"p $out2.sort|awk '{print $3}'`
echo $cutoff1 $cutoff2
awk "\$3 >= $cutoff1" $out1.sort >$out1.sweep
awk "\$3 >= $cutoff2" $out2.sort >$out2.sweep
echo "--- End Time : `date` ---"
#**********************************************

posted @ 2011-11-04 13:39  ACE封印  Views(355)  Comments(0Edit  收藏  举报