Search for specific file type in subdirectory with multiple folders
I have a directory that is in the below order (the --- is not part of the directory tree, only there to help illustrate:
The bash below reads each line in out.txt and uses that in a below. So for this example a would be /home/cmccabe/nfs/exportedReports/Folder1. What I am having trouble with is the vcf.gz being searched for is two more levels down (last level in the above). /home/cmccabe/nfs/exportedReports/plugin_out/variantCaller_out.40/001. The level right before that /home/cmccabe/nfs/exportedReports/plugin_out/variantCaller_out.40 is consistent unitil the ., then the numbers varies. So in this example variantCaller_out.40 the portion in bold will change. The last level has 3 folders 001, 002, 003 that the vcf.gz can be found in.
I guess what I am trying to do is search for each vcf.gzin
Bash
contents of out.txt
within Folder1
next level Folder1/plugin_out
next level Folder1/plugin_out/variantCaller_out.40
Currently I am getting syntax errors. Thank you .
Last edited by cmccabe; 09-19-2016 at 04:40 PM..
Reason: added details
If you are getting syntax errors, have you tried using set -x. This will let you see the exact commands being executed with variables being replaced with actual values.
Last edited by rbatte1; 09-20-2016 at 05:29 AM..
Reason: Changed CODE tags to ICODE tags
set -x showed that, while I am still not sure of the best way to accomplish this, the final vcf.gz that comes from the 001 folder is called variants.vcf.gz. The final vcf.gz that comes from the 002 folder is also called variants.vcf.gz. So unless the files are named differently somehow they are always going to be replaced. Thank you .
set -x showed that, while I am still not sure of the best way to accomplish this, the final vcf.gz that comes from the 001 folder is called variants.vcf.gz. The final vcf.gz that comes from the 002 folder is also called variants.vcf.gz. So unless the files are named differently somehow they are always going to be replaced. Thank you .
Hello cmccabe,
I am sorry, I am confused about your requirement. But by seeing your findcommand I could say you need to copy few files by finding them from one location to another and copy to detination directory, so you could try to change your command with following(not tested though).
It will copy all matched files to destination directory. Please try it and do let us know how it goes then. If your requirement is different then please be more clear and specific in your requirements.
Thanks,
R. Singh
Last edited by RavinderSingh13; 09-20-2016 at 05:38 AM..
Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried:
grep -lr "this string" *
but I do not... (3 Replies)
I am trying to write a script that cycles through a folder containing many folders and when inside each one it's supposed to copy all the .fna.gz files to a folder elsewhere if the file and the respective folder have the same name.
for fldr in /home/playground/genomes/* ; do
find .... (8 Replies)
I have a simple function that greps within a folder into files that are already gunzipped. This was already written for me so from my understanding fn=$1 specifies that it will look into any file in that folder that is gunzipped and the rest of the script greps the data its looking for and puts it... (3 Replies)
hi I want to write a script which count the number of subdirectories in the current root directory that contain more than a specified number of files of a specific type. Is there an easy way to do this?
Thanks
Robert (2 Replies)
Hi,
I have a script that handles a huge amount of log files from many machines and copies it into a SAN location with the following directory structure:
/SAN/machinenames/yyyy/m/d
so for example
/SAN/hosta/2011/3/12/files*
Now I am writing a bash script to search for files between to date... (4 Replies)
Hi I made this code to search in directory for file and size
How can I remodel it to seach in the sub direcotry as well
Thanks
#!/bin/bash
echo -n "Enter: "
read var
if
then
echo "Directory exists: ${var}"
size=`du -hs "${var}"`
echo The size of the current folder is... (4 Replies)
Ok question number two: I'd like to search a directory for multiple file types (rar, txt, deb) and depending on what's found, copy those files to folders named Rar, TextFiles, and Debs. I'm looking for speed here so the faster the script the better. I want it to be a function that I pass 1 argument... (4 Replies)
Hi All,
I was exploring find command and came across -prune option which would exclude search in a mention subdirectory.
My quesry is to search all files more that 100 MB size but exclude search in a subdirectory.
I am using below command,but somehow it is not working.
Can anybody help me... (6 Replies)
Hi,
I need to search for some strings in specific positions in a file.
If the strings: "foo1", "foo2" or "foo3" is on position 266 or position 288 in a file i want the whole line printed.
Any idea how to do it? (5 Replies)
Hi,
I am newbie in UNIX so please excuse for my questions.
Is there a a way to search for string in files within folder and sub folder in particluar file extensions.
Ex. search for ABC in folder 'A'(including it's sub folders) in html, xml files.
Thanks,
Ani (2 Replies)