
.vcf
variants folder
ID가 있는 폴더 에 각 파일을 mv하려고 합니다 . in은 항상 변형 폴더에서 a의 ID를 갖습니다. 로 시작하는 줄은 항상 의 폴더와 정확히 일치합니다. 에는 폴더가 여러 개 있을 수 있지만 에서는 일치하는 폴더가 하나만 있습니다. 여러 개의 ID가 있을 수도 있지만 ./home/cmccabe/f2
.vcf
file
$2
file
.vcf
file
R_2019
-v5.6
/home/cmccabe/f2
/home/cmccabe/f2
file
.vcf
/home/cmccabe/f1/variants
/home/cmccabe/f2
의 폴더와 의 폴더 R_2019
간에 일치하는 항목이 발견 되면 file
의 ID가 검색 $2
됩니다 . 그런 다음 각 파일은 새 하위 폴더 의 일치하는 폴더 로 이동됩니다. 실행은 되지만 파일은 이동되지 않습니다. 감사해요:)./home/cmccabe/f1/variants
.vcf
.vcf
/home/cmccabe/f2
variants
bash
문서/home/cmccabe/f1에서
IonCode_0007 19-0004-La-Fi
IonCode_0009 19-0005-Last-Firs
IonCode_0013 190320-Control
R_2019_03_12_13_59_54_user_S5-0271-100-v5.6_xxx_xxx_xxx_xxx_xx_x_xxx
변형 폴더존재하다/home/cmccabe/f1
19-0004-La-Fi.vcf
19-0005-Last-Firs.vcf
190320-Control.vcf
현재 구조~의/home/cmccabe/f2
R_2019_03_12_13_59_54_user_S5-0271-100 ---parent directory ---
- bam --- sub-folder ---
- qc --- sub-folder ---
필요한 구조~의/home/cmccabe/f2
R_2019_03_12_13_59_54_user_S5-0271-100 ---parent directory ---
- bam --- sub-folder ---
- qc --- sub-folder ---
- variants --- new sub-folder ---
- 19-0004-La-Fi.vcf
- 19-0005-Last-Firs.vcf
- 190320-Control.vcf
타격 가능성
for file in /home/cmccabe/f1/variants/*.vcf ; do
# Grab file prefix
bname=$(basename $file) # strip of path
VCF="$(echo $bname|cut -d. -f1)" # remove .vcf extension
f=$(printf '%s' /home/cmccabe/f1/file/${VCF}) ## # Find matching id
FILE2=$(awk '{print $2}' $f) # set VCF lookup to column
for RDIR in /home/cmccabe/f1/file/R_2019* ; do FOLDER=${RDIR%%-v5.6*}; done ## trim R_2019 line in file from -v5.6 and store in FOLDER
if [[ $VCF = $FILE2 ]] # only execute file on match
then
mkdir -p /home/cmccabe/f2/$FOLDER/variants ## create variants sub-folder
mv /home/cmccabe/f1/file/$VCF /home/cmccabe/f2/$FOLDER/variants ## move vcf to folder
fi ## end if
done ## close loop