Linux学习6之shell筛选当前目录下文件并逐个对其进行操作
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
代码:
hadoop@Master:~/cloud/adam/xubo/code$ cat a.sh
#!/bin/bash
#SRR003161h20t1
#samtools view -h -S SRR003161h20t1.sam >SRR003161h20t1.bam
#samtools sort -o SRR003161h20t1.sorted.bam SRR003161h20t1.bam
#samtools view -h -S SRR003161h20t1.sam |samtools sort -o SRR003161h20t1Sort.bam
# samtools sort -o toy.sorted.bam toy.bam
dir=$(ls -l ./ |awk '!/^d/ {print $NF}' |grep -i "sam" )
for i in $dir
do
#echo $i
startTime=`date +"%s.%N"`
s1=$(echo $i | cut -d '.' -f 1)
samtools view -h -S $i |samtools sort -o $s1.sort.bam
endTime=`date +"%s.%N"`
echo $i" "`awk -v x1="$(echo $endTime | cut -d '.' -f 1)" -v x2="$(echo $startTime | cut -d '.' -f 1)" -v y1="$[$(echo $endTime | cut -d '.' -f 2) / 1000]" -v y2="$[$(echo $startTime | cut -d '.' -f 2) /1000]" 'BEGIN{printf " RunTIme:%.6f s",(x1-x2)+(y1-y2)/1000000}'`
done
运行语句:
hadoop@Mcnode4:~/cloud/adam/xubo/data/test20160310/bwa3sh/test<span style="font-size: 13.3333px; font-family: Arial, Helvetica, sans-serif;">142234</span><span style="font-size: 12px; font-family: Arial, Helvetica, sans-serif;">$ ./a.sh &> s2bambwaMcnode4T201603152115.txt</span>
运行结果:
hadoop@Mcnode4:~/cloud/adam/xubo/data/test20160310/bwa3sh/test142234$ cat s2bambwaMcnode4201603152104.txt
SRR003161h100000t1.sam RunTIme:2.245094 s
SRR003161h100000t2.sam RunTIme:2.248639 s
SRR003161h100000t3.sam RunTIme:2.258191 s
SRR003161h10000t1.sam RunTIme:0.286576 s
SRR003161h10000t2.sam RunTIme:0.275169 s
SRR003161h10000t3.sam RunTIme:0.280443 s
./a.sh: line 17: 087064391: value too great for base (error token is "087064391")
SRR003161h1000t2.sam
./a.sh: line 17: 093253589: value too great for base (error token is "093253589")
SRR003161h1000t3.sam
SRR003161h20t1.sam RunTIme:0.050949 s
SRR003161h20t2.sam RunTIme:0.058536 s
SRR003161h20t3.sam RunTIme:0.041384 s
[bam_sort_core] merging from 3 files...
SRR003161t1.sam RunTIme:164.763129 s
[bam_sort_core] merging from 3 files...
SRR003161t2.sam RunTIme:166.538254 s
[bam_sort_core] merging from 3 files...
hadoop@Mcnode4:~/cloud/adam/xubo/data/test20160310/bwa3sh/test142234$ ll -h
total 6.7G
drwxrwxr-x 3 hadoop hadoop 4.0K 3月 15 21:10 ./
drwxrwxr-x 4 hadoop hadoop 4.0K 3月 15 19:39 ../
-rwx------ 1 hadoop hadoop 797 3月 15 21:02 a.sh*
drwxrwxr-x 2 hadoop hadoop 4.0K 3月 15 20:17 fff/
-rw-rw-r-- 1 hadoop hadoop 776 3月 15 21:10 s2bambwaMcnode4201603152104.txt
-rwx------ 1 hadoop hadoop 4.8K 3月 15 20:09 s2b.sh*
-rwx------ 1 hadoop hadoop 354 3月 15 20:18 showDirectory.sh*
-rwx------ 1 hadoop hadoop 450 3月 15 20:25 showFileAndDirectory.sh*
-rw-rw-r-- 1 hadoop hadoop 106K 3月 14 22:40 SRR003161h100000t1.sai
-rw-rw-r-- 1 hadoop hadoop 29M 3月 14 22:41 SRR003161h100000t1.sam
-rw-rw-r-- 1 hadoop hadoop 9.5M 3月 15 21:04 SRR003161h100000t1.sort.bam
-rw-rw-r-- 1 hadoop hadoop 106K 3月 14 22:48 SRR003161h100000t2.sai
-rw-rw-r-- 1 hadoop hadoop 29M 3月 14 22:49 SRR003161h100000t2.sam
-rw-rw-r-- 1 hadoop hadoop 9.5M 3月 15 21:04 SRR003161h100000t2.sort.bam
-rw-rw-r-- 1 hadoop hadoop 106K 3月 14 22:57 SRR003161h100000t3.sai
-rw-rw-r-- 1 hadoop hadoop 29M 3月 14 22:58 SRR003161h100000t3.sam
-rw-rw-r-- 1 hadoop hadoop 9.5M 3月 15 21:04 SRR003161h100000t3.sort.bam
-rw-rw-r-- 1 hadoop hadoop 11K 3月 14 22:38 SRR003161h10000t1.sai
-rw-rw-r-- 1 hadoop hadoop 3.0M 3月 14 22:39 SRR003161h10000t1.sam
-rw-rw-r-- 1 hadoop hadoop 1001K 3月 15 21:04 SRR003161h10000t1.sort.bam
-rw-rw-r-- 1 hadoop hadoop 11K 3月 14 22:46 SRR003161h10000t2.sai
-rw-rw-r-- 1 hadoop hadoop 3.0M 3月 14 22:47 SRR003161h10000t2.sam
-rw-rw-r-- 1 hadoop hadoop 1001K 3月 15 21:04 SRR003161h10000t2.sort.bam
-rw-rw-r-- 1 hadoop hadoop 11K 3月 14 22:54 SRR003161h10000t3.sai
-rw-rw-r-- 1 hadoop hadoop 3.0M 3月 14 22:55 SRR003161h10000t3.sam
-rw-rw-r-- 1 hadoop hadoop 1001K 3月 15 21:04 SRR003161h10000t3.sort.bam
-rw-rw-r-- 1 hadoop hadoop 1.1K 3月 14 22:36 SRR003161h1000t1.sai
-rw-rw-r-- 1 hadoop hadoop 1.1K 3月 14 22:44 SRR003161h1000t2.sai
-rw-rw-r-- 1 hadoop hadoop 339K 3月 14 22:45 SRR003161h1000t2.sam
-rw-rw-r-- 1 hadoop hadoop 111K 3月 15 21:04 SRR003161h1000t2.sort.bam
-rw-rw-r-- 1 hadoop hadoop 1.1K 3月 14 22:52 SRR003161h1000t3.sai
-rw-rw-r-- 1 hadoop hadoop 339K 3月 14 22:53 SRR003161h1000t3.sam
-rw-rw-r-- 1 hadoop hadoop 111K 3月 15 21:04 SRR003161h1000t3.sort.bam
-rw-rw-r-- 1 hadoop hadoop 22K 3月 15 20:07 SRR003161h20t1.bam
-rw-rw-r-- 1 hadoop hadoop 88 3月 14 22:34 SRR003161h20t1.sai
-rw-rw-r-- 1 hadoop hadoop 22K 3月 14 22:35 SRR003161h20t1.sam
-rw-rw-r-- 1 hadoop hadoop 9.0K 3月 15 21:04 SRR003161h20t1.sort.bam
-rw-rw-r-- 1 hadoop hadoop 9.0K 3月 15 20:07 SRR003161h20t1Sort.bam
-rw-rw-r-- 1 hadoop hadoop 88 3月 14 22:42 SRR003161h20t2.sai
-rw-rw-r-- 1 hadoop hadoop 22K 3月 14 22:43 SRR003161h20t2.sam
-rw-rw-r-- 1 hadoop hadoop 9.0K 3月 15 21:04 SRR003161h20t2.sort.bam
-rw-rw-r-- 1 hadoop hadoop 88 3月 14 22:50 SRR003161h20t3.sai
-rw-rw-r-- 1 hadoop hadoop 22K 3月 14 22:51 SRR003161h20t3.sam
-rw-rw-r-- 1 hadoop hadoop 9.0K 3月 15 21:04 SRR003161h20t3.sort.bam
-rw-rw-r-- 1 hadoop hadoop 36M 3月 15 19:58 SRR003161t1.bam
-rw-rw-r-- 1 hadoop hadoop 5.7M 3月 14 23:53 SRR003161t1.sai
-rw-rw-r-- 1 hadoop hadoop 1.6G 3月 15 00:09 SRR003161t1.sam
-rw-rw-r-- 1 hadoop hadoop 513M 3月 15 21:06 SRR003161t1.sort.bam
-rw-rw-r-- 1 hadoop hadoop 5.7M 3月 15 01:04 SRR003161t2.sai
-rw-rw-r-- 1 hadoop hadoop 1.6G 3月 15 01:21 SRR003161t2.sam
-rw-rw-r-- 1 hadoop hadoop 513M 3月 15 21:09 SRR003161t2.sort.bam
-rw-rw-r-- 1 hadoop hadoop 5.7M 3月 15 02:17 SRR003161t3.sai
-rw-rw-r-- 1 hadoop hadoop 1.6G 3月 15 02:32 SRR003161t3.sam
-rw-rw-r-- 1 hadoop hadoop 389M 3月 15 21:12 SRR003161t3.sort.bam
-rw-rw-r-- 1 hadoop hadoop 272M 3月 15 21:10 STDIN.tmp.0000.bam
-rw-rw-r-- 1 hadoop hadoop 256M 3月 15 21:10 STDIN.tmp.0001.bam
-rw-rw-r-- 1 hadoop hadoop 31M 3月 15 21:10 STDIN.tmp.0002.bam
-rwx------ 1 hadoop hadoop 276 3月 15 20:07 te.sh*
-rw------- 1 hadoop hadoop 12K 3月 15 20:03 .te.sh.swp
GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献13条内容
所有评论(0)