Skip to content
Snippets Groups Projects

Add files to bash_scripts

Open Tom Nichols requested to merge nichols/ukb_unconfound_v2:Update_bash_scripts into master
1 file
+ 37
0
Compare changes
  • Side-by-side
  • Inline
+ 37
0
#/bin/bash
tmpn=`tmpnam /tmp/bb_`
fil1=$1
fil2=$2
outDir=$3
if [ "$fil1" == "" ] ; then
echo "Error: 2 files needed"
exit
fi
if [ "$fil2" == "" ] ; then
echo "Error: 2 files needed"
exit
fi
if [ "$outDir" == "" ] ; then
outDir=`pwd`
fi
if [ ! -f $fil1 ] ; then
echo "Error: File $fil1 is not accessible"
exit
fi
if [ ! -f $fil2 ] ; then
echo "Error: File $fil2 is not accessible"
exit
fi
cat $fil1 $fil2 | sort | uniq > $outDir/A_or_B.txt
cat $fil1 $fil2 | sort | uniq -c | grep " 2 " | awk '{print $2}' > $outDir/A_and_B.txt
cat $fil1 $fil2 | sort | uniq -c | grep " 1 " | awk '{print $2}' > $tmpn
cat $fil1 $tmpn | sort | uniq -c | grep " 1 " | awk '{print $2}' > ${tmpn}_1
cat ${tmpn}_1 $tmpn | sort | uniq -c | grep " 2 " | awk '{print $2}' > $outDir/B_not_A.txt
cat $fil2 $tmpn | sort | uniq -c | grep " 1 " | awk '{print $2}' > ${tmpn}_2
cat ${tmpn}_2 $tmpn | sort | uniq -c | grep " 2 " | awk '{print $2}' > $outDir/A_not_B.txt
rm $tmpn ${tmpn}_1 ${tmpn}_2
Loading