Saturday, November 20, 2010

awk.gsub, awk.system

Tips in Computer: "awk '{system('grep ' $4 ' file > result.txt'); getline result < 'result.txt'; close('result.txt'); print result;}' infile

e.g File
/scratch/dongx/jobid_2622600/18_2_62LPFAAXX_092810_MyersLab_4242.fastq.tophat.mm_1.unique.hg19.out/accepted_hits.bam
/scratch/dongx/jobid_2622600/18_2_62LPFAAXX_092810_MyersLab_4242.fastq.tophat.mm_1.unique.hg19.out/junctions.bed
/scratch/dongx/jobid_2622604/20_2_62MA2AAXX_101210_MyersLab_4430_4.fastq.tophat.mm_1.unique.hg19.out/accepted_hits.bam
/scratch/dongx/jobid_2622604/20_2_62MA2AAXX_101210_MyersLab_4430_4.fastq.tophat.mm_1.unique.hg19.out/junctions.bed
/scratch/dongx/jobid_2622606/20_5_62MA2AAXX_101210_PhiX.fastq.tophat.mm_1.unique.hg19.out/accepted_hits.bam

You want to copy the .bam and .bed file to another folder...

$ cat > tophat.log
$ grep "s\.b" tophat.log | awk '{a=$1; gsub(".*[0-9]/","", a); sub("/",".", a); system("cp " $1 " " a);}'

- Sent using Google Toolbar"

No comments:

Post a Comment