아래 내용 볼 필요 없이 이거쓰면 됨
find . -name "*패턴*" -exec mv {} ./results \;
설명
원하는 파일 예를들어 fastq.gz이 여러 개의 폴더에 나뉘어져 있는 경우가 있음.
아래는 그 예시
NT60 : NT60_1.fastq.gz, NT60_2.fastq.gz
NT61 : NT61_1.fastq.gz, NT61_2.fastq.gz
...
원하는 패스로 옮겨주는 스크립트 만드는거임
copy & paste
#!/bin/bash
# This script is to copy & paste files that share a part of name and are located in multiple folders.
# Once the files are copied, they will be pasted in a directory that you want.
#
# Get target directory path
echo 'Provide target directory path where you want to locate your copied files.'
echo 'ex : /mnt/bigHDD/~~~/'
read target_path
# Create target path folder?
echo 'Should target folder be created? (yes,y/no,n)'
read yes
echo "Your decided $yes"
if [ "$yes" = "y" ] || [ "$yes" = "yes" ] || [ "$yes" = "Y" ]; then
echo 'Create target folder'
mkdir -p -m 777 $target_path
echo 'Target path folder created'
fi
# Get file list
echo 'Put file name pattern (ex. fastq.gz)'
read file_pattern
# Create file list
file_pattern2=*$file_pattern*
find . -name $file_pattern2 > tmp.txt
#===============================
# For loop for copy and paste files
#===============================
echo 'Copy and paste process is initiated'
for j in $(cat tmp.txt)
do
echo $j
cp $j $target_path
done
#========================================
# Remove temporary files
#========================================
rm -rf tmp.txt
echo 'Process finished'
파일을 다운 받고 아래와 같이 설치하면 됨
nano ~/.bashrc
맨 아래에 아래의 글을 추가함
alias cpnp='sh /파일 깔린곳/파일.sh'
컨트롤+x 누르기
y 누르기
enter키 누르기
. ~/.bashrc