Bash to add folder to exsisting folders in directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash to add folder to exsisting folders in directory
# 1  
Old 10-03-2016
Bash to add folder to exsisting folders in directory

I am trying to create subdirectories in each folder in /home/cmccabe/Desktop/NGS/test/*. When I use echo I can see each folder in the directory, but I can not seem to add the commented out portion in bold. These are the sub-directories and sub-folders I am trying to add to each folder in /home/cmccabe/Desktop/NGS/test/*. Thank you Smilie.

Bash
Code:
 for D in /home/cmccabe/Desktop/NGS/test/*; do
    if [ -d "$D" ]; then
        cd "$D"
        echo "$D"  
#bam/{validation,coverage},bedtools,fastqc,hgmd,igv,panel/{reads,},panel/20x/{base,gene,percent},panel/{reads,},panel/30x/{base,gene,percent},picard,torrent,vcf/overall/{annovar,stats},vcf/panel/{annovar,}} #
    fi
done

Folders in /home/cmccabe/Desktop/NGS/test/[/ICODE]
Code:
 Folder1
 Runfolder2
 Run3

Example:
Code:
 Folder 1 - folder in ]/home/cmccabe/Desktop/NGS/test
 BAM
   -validation
   -coverage
 Bedtools
 FASTQC
 HGMD
 IGV
 Panel
   - 20x
reads  
 base genes percent
   - 30x
reads  
 base genes percent
 Picard
 Torrent
 VCF
    - overall
 annovar, stats
   - Panel
 annovar


Last edited by cmccabe; 10-03-2016 at 03:49 PM.. Reason: fixed format
# 2  
Old 10-03-2016
It seems that you would want to replace the bold code by one or more:
Code:
        mkdir -p "$D/possibly_missing_directory" ...

commands. Given differences in case, differences in leading hyphens and/or spaces, and confusing uses of commas (sometimes separating lists of directories to be created and sometimes apparently being part of the name of a directory being created [<space>annovar,<space>stats]), I am not going to try to guess at which actual mkdir commands you need to do what you really want to do.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash to check directory and create missing folder from file

In the below bash I am trying to ensure that all folders (represented by $folders) in a given directory are created. In the file f1 the trimmed folder will be there somewhere (will be multiple trimmed folders). When that trimmed folder is found (represented by $S5) the the contents of $2 printed... (19 Replies)
Discussion started by: cmccabe
19 Replies

2. Shell Programming and Scripting

Bash to add unique prefix to extracted zip folder

In the bash below in each .zip there is a folder to be extracted Variants that I am trying to make unique by adding the prefix, before the _ from the .zip. The script does execute, but the prefix is not added to the extracted folder. Rather the Variants folder is added to each file within it. Thank... (1 Reply)
Discussion started by: cmccabe
1 Replies

3. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

4. Shell Programming and Scripting

How can i move folders and its content if folder is older than 1,5 days and keep subdirs in bash?

Hello all, do you know any way i can i move folders and its content if folder is older than 1,5 days in bash? I tried: find /home/xyz/DATA/* -type d -ctime +1.5 -exec mv "{}" /home/xyz/move_data_here/ \;All i got was that Files from DATA /home/xyz/DATA/* ended messed up in... (1 Reply)
Discussion started by: ZerO13
1 Replies

5. Shell Programming and Scripting

Bash directory loop, but only choose those folders with specific word in it

Hello, how in bash i can get directory loop, but only choose those folders with specific word in it, so it will only echo those with specific word #!/bin/bash for filename in /home/test/* do if ; then echo $filename; fithx! (4 Replies)
Discussion started by: ZerO13
4 Replies

6. Shell Programming and Scripting

Bash to select oldest folder in directory and write to log

In the bash below the oldest folder in a directory is selected. If there are 3folders in the directory /home/cmccabe/Desktop/NGS/test and nothing is done to them (ie. no files deleted, renamed) then the bash correctly identifies f1 as the oldest. However, if something is done to the folder then... (4 Replies)
Discussion started by: cmccabe
4 Replies

7. Shell Programming and Scripting

Bash to list all folders in a specific directory

The below bash is trying to list the folders in a specific directory. It seems close but adds the path to the filename, which basename could strip off I think, but not sure why it writes the text file created? This list of folders in the directory will be used later, but needs to only be the... (5 Replies)
Discussion started by: cmccabe
5 Replies

8. Shell Programming and Scripting

Bash to select oldest folder in directory automatically and log process

The `bash` below uses the oldest folder in the specified directory and logs it. The goes though an analysis process and creates a log. My problem is that if there are 3 folders in the directory folder1,folder2,folder3, the bash is using folder2 for the analysis eventhough folder1 is the oldest... (0 Replies)
Discussion started by: cmccabe
0 Replies

9. Shell Programming and Scripting

How to delete other's folders which are in our own folder?

Hi All, I need a solution for the following scenario. I am the owner for the particular folder and I have given 777 permissions for some specific reasons. So others can able to create folders and files. But when I am done with the work, I need to delete the folders which are created by... (4 Replies)
Discussion started by: manoj_thorali
4 Replies

10. UNIX for Dummies Questions & Answers

Need to add aditional space on an exsisting Linux Partition..

Hi, I need to add more space to an exsisting /u partition by adding an additional physical drive, so that the additional space is added in continuation to the exsisting /u diskspace. Is it possible...if yes....how do I go about it. Thanks, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies
Login or Register to Ask a Question