具体示例:
ls ../sample_*/*/*rmp.bam
../sample_10/10-1/10_rep1_rmp.bam ../sample_13/13-1/13_rep1_rmp.bam ../sample_2/2-1/2_rep1_rmp.bam ../sample_6/6-1/6_rep1_rmp.bam
../sample_10/10-2/10_rep2_rmp.bam ../sample_13/13-2/13_rep2_rmp.bam ../sample_2/2-2/2_rep2_rmp.bam ../sample_6/6-2/6_rep2_rmp.bam
../sample_10/10-3/10_rep3_rmp.bam ../sample_13/13-3/13_rep3_rmp.bam ../sample_2/2-3/2_rep3_rmp.bam ../sample_6/6-3/6_rep3_rmp.bam
../sample_11/11-1/11_rep1_rmp.bam ../sample_14/14-1/14_rep1_rmp.bam ../sample_3/3-1/3_rep1_rmp.bam ../sample_7/7-1/7_rep1_rmp.bam
../sample_11/11-2/11_rep2_rmp.bam ../sample_14/14-2/14_rep2_rmp.bam ../sample_3/3-2/3_rep2_rmp.bam ../sample_7/7-2/7_rep2_rmp.bam
../sample_11/11-3/11_rep3_rmp.bam ../sample_14/14-3/14_rep3_rmp.bam ../sample_3/3-3/3_rep3_rmp.bam ../sample_7/7-3/7_rep3_rmp.bam
../sample_1/1-1/1_rep1_rmp.bam ../sample_15/15-1/15_rep1_rmp.bam ../sample_4/4-1/4_rep1_rmp.bam ../sample_8/8-1/8_rep1_rmp.bam
../sample_1/1-2/1_rep2_rmp.bam ../sample_15/15-2/15_rep2_rmp.bam ../sample_4/4-2/4_rep2_rmp.bam ../sample_8/8-2/8_rep2_rmp.bam
../sample_1/1-3/1_rep3_rmp.bam ../sample_15/15-3/15_rep3_rmp.bam ../sample_4/4-3/4_rep3_rmp.bam ../sample_8/8-3/8_rep3_rmp.bam
../sample_12/12-1/12_rep1_rmp.bam ../sample_16/16-1/16_rep1_rmp.bam ../sample_5/5-1/5_rep1_rmp.bam ../sample_9/9-1/9_rep1_rmp.bam
../sample_12/12-2/12_rep2_rmp.bam ../sample_16/16-2/16_rep2_rmp.bam ../sample_5/5-2/5_rep2_rmp.bam ../sample_9/9-2/9_rep2_rmp.bam
../sample_12/12-3/12_rep3_rmp.bam ../sample_16/16-3/16_rep3_rmp.bam ../sample_5/5-3/5_rep3_rmp.bam ../sample_9/9-3/9_rep3_rmp.bam
想截取红色框子里面的字符
image.png
按照前面的命令写如下脚本:
for i in `ls ../sample_*/*/*rmp.bam`
do
sample=${i##*/}
name=${sample%.*}
echo $i
echo ${name}.bw
done
储存并运行
bash test.sh
../sample_10/10-1/10_rep1_rmp.bam
10_rep1_rmp.bw
../sample_10/10-2/10_rep2_rmp.bam
10_rep2_rmp.bw
../sample_10/10-3/10_rep3_rmp.bam
10_rep3_rmp.bw
../sample_11/11-1/11_rep1_rmp.bam
11_rep1_rmp.bw
../sample_11/11-2/11_rep2_rmp.bam
11_rep2_rmp.bw
../sample_11/11-3/11_rep3_rmp.bam
11_rep3_rmp.bw
../sample_1/1-1/1_rep1_rmp.bam
1_rep1_rmp.bw
../sample_1/1-2/1_rep2_rmp.bam
1_rep2_rmp.bw
../sample_1/1-3/1_rep3_rmp.bam
1_rep3_rmp.bw
../sample_12/12-1/12_rep1_rmp.bam
12_rep1_rmp.bw
../sample_12/12-2/12_rep2_rmp.bam
12_rep2_rmp.bw
../sample_12/12-3/12_rep3_rmp.bam
12_rep3_rmp.bw
../sample_13/13-1/13_rep1_rmp.bam
13_rep1_rmp.bw
../sample_13/13-2/13_rep2_rmp.bam
13_rep2_rmp.bw
../sample_13/13-3/13_rep3_rmp.bam
...
网友评论