Sponsored Content
Top Forums Shell Programming and Scripting Bash to move specific files to directory based on match to file Post 303033644 by cmccabe on Tuesday 9th of April 2019 09:20:30 PM
Old 04-09-2019
I have been able to get a working solution that produces my desired results... using set -x and the below modifications

Code:
if [[ $VCF = ${STRING[*]} ]] # only execute file on match
         then
           RSTRING=$(awk '/R_2019/' "$DIR"/run)  ## search for lines matching R_2019 pattern
              VCFRUN=$(awk -F '\n' -v RS="" -v ref="$VCF" '$0 ~ ref {print $NF}' "$DIR"/file)  ## search file for matching $VCF and return last column ($2)
           RUN="$(echo $RSTRING|cut -d- -f1,2,3)" ## remove after third _ in line with R_2019
                mv "$DIR"/variants/${VCF}.vcf "$DEST"/"$RUN"/"$VCF"/variants  ## move vcf to folder in destination

This matched each .vcf and moved the match to the correct run file. Maybe this will help others as well.

Thank you very much for your help Smilie.

Last edited by cmccabe; 04-09-2019 at 10:22 PM.. Reason: added comments
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge two file data together based on specific pattern match

My input: File_1: 2000_t g1110.b1 abb.1 2001_t g1111.b1 abb.2 abb.2 g1112.b1 abb.3 2002_t . . File_2: 2000_t Ali england 135 abb.1 Zoe british 150 2001_t Ali england 305 g1111.b1 Lucy russia 126 (6 Replies)
Discussion started by: patrick87
6 Replies

2. UNIX for Advanced & Expert Users

Watch directory and move specific file extensions

Hi all, This is actually more for my lazyness then anything else, but I think others might find it useful to use as well. Basically this is what I am trying to achieve... In my ubuntu home dir under Downloads is where firefox saves everything by default, now I know that you can manually... (3 Replies)
Discussion started by: STOIE
3 Replies

3. Shell Programming and Scripting

Move all files from source to destination directory based on the filename

Move all files starting with a specific name to different directory. This shell script program should have three parameters File Name Source Directory Destination Directory User should be able to enter ‘AB_CD*' in file name parameter. In this case all the files starting with AB_CD will... (1 Reply)
Discussion started by: chetancrsp18
1 Replies

4. Shell Programming and Scripting

Move files to another directory based on name

Hi Folks, I have different type of file in my current directory. From my current directory i need to move the file which is start with csp_rules and if the file is having the string payg , then I need to move all this files to another directory /output/record. Please help me how to do this? ... (3 Replies)
Discussion started by: suresh01_apk
3 Replies

5. Shell Programming and Scripting

Move files from one directory to another based on creation/modification date

Hi All, Really stuck up with a requirement where I need to move a file (Lets say date_Employee.txt--the date will have different date values like 20120612/20120613 etc) from one directory to another based on creation/modification dates. While visiting couple of posts, i could see we can... (3 Replies)
Discussion started by: dsfreddie
3 Replies

6. UNIX for Dummies Questions & Answers

move files that match specific conditions

Hi all, I'm new to this forum and bash scripting. I have the following problem, I need to copy some files (from one dir. to another) whose first 5 numbers (subjects' ID) match the directory names. Here a shortened version of what I'm trying to do: names=(32983_f 35416_f 43579_f) # these are... (6 Replies)
Discussion started by: ada1983
6 Replies

7. Shell Programming and Scripting

Bash to select panel then specific file in directory

I am using bash to prompt a user for a choice using: where a "y" response opens a menu with available panels that can be used. while true; do read -p "Do you want to get coverage of a specific panel?" yn case $yn in * ) menu; break;; * ) exit;; * ) echo... (6 Replies)
Discussion started by: cmccabe
6 Replies

8. Shell Programming and Scripting

Rename specific file extension in directory with match to another file in bash

I have a specific set (all ending with .bam) of downloaded files in a directory /home/cmccabe/Desktop/NGS/API/2-15-2016. What I am trying to do is use a match to $2 in name to rename the downloaded files. To make things a more involved the date of the folder is unique and in the header of name... (1 Reply)
Discussion started by: cmccabe
1 Replies

9. Shell Programming and Scripting

Bash to move specific files from folders in find file

I have a directory /home/cmccabe/nfs/exportedReports that contains multiple folders in it. The find writes the name of each folder to out.txt. A new directory is then created in a new location /home/cmccabe/Desktop/NGS/API, named with the date. What I am trying to do, unsuccessfully at the moment,... (7 Replies)
Discussion started by: cmccabe
7 Replies

10. Shell Programming and Scripting

Bash to add portion of text to files in directory using numerical match

In the below bash I am trying to rename eachof the 3 text files in /home/cmccabe/Desktop/percent by matching the numerical portion of each file to lines 3,4, or 5 in /home/cmccabe/Desktop/analysis.txt. There will always be a match between the files. When a match is found each text file in... (2 Replies)
Discussion started by: cmccabe
2 Replies
VCF-ANNOTATE(1) 						   User Commands						   VCF-ANNOTATE(1)

NAME
vcf-annotate - annotate VCF file, add filters or custom annotations SYNOPSIS
cat in.vcf | vcf-annotate [OPTIONS] > out.vcf DESCRIPTION
About: Annotates VCF file, adding filters or custom annotations. Requires tabix indexed file with annotations. Currently annotates only the INFO column, but it will be extended on demand. OPTIONS
-a, --annotations <file.gz> The tabix indexed file with the annotations: CHR FROM[ TO][ VALUE]+. -c, --columns <list> The list of columns in the annotation file, e.g. CHROM,FROM,TO,-,INFO/STR,INFO/GN. The dash in this example indicates that the third column should be ignored. If TO is not present, it is assumed that TO equals to FROM. -d, --description <file|string> Header annotation, e.g. key=INFO,ID=HM2,Number=0,Type=Flag,Description='HapMap2 membership'. The descriptions can be read from a file, one annotation per line. -f, --filter <list> Apply filters, list is in the format flt1=value/flt2/flt3=value/etc. -h, -?, --help This help message. Filters: + Apply all filters with default values (can be overridden, see the example below). -X Exclude the filter X 1, StrandBias FLOAT Min P-value for strand bias (given PV4) [0.0001] 2, BaseQualBias FLOAT Min P-value for baseQ bias [1e-100] 3, MapQualBias FLOAT Min P-value for mapQ bias [0] 4, EndDistBias FLOAT Min P-value for end distance bias [0.0001] a, MinAB INT Minimum number of alternate bases [2] c, SnpCluster INT1,INT2 Filters clusters of 'INT1' or more SNPs within a run of 'INT2' bases [] D, MaxDP INT Maximum read depth [10000000] d, MinDP INT Minimum read depth [2] q, MinMQ INT Minimum RMS mapping quality for SNPs [10] Q, Qual INT Minimum value of the QUAL field [10] r, RefN Reference base is N [] W, GapWin INT Window size for filtering adjacent gaps [10] w, SnpGap INT SNP within INT bp around a gap to be filtered [10] Example: zcat in.vcf.gz | vcf-annotate -a annotations.gz -d descriptions.txt | bgzip -c >out.vcf.gz zcat in.vcf.gz | vcf-annotate -f +/-a/c=3,10/q=3/d=5/-D -a annotations.gz -d descriptions.txt | bgzip -c >out.vcf.gz Where descriptions.txt contains: key=INFO,ID=GN,Number=1,Type=String,Description='Gene Name' key=INFO,ID=STR,Number=1,Type=Integer,Description='Strand' vcf-annotate 0.1.5 July 2011 VCF-ANNOTATE(1)
All times are GMT -4. The time now is 07:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy