Sponsored Content
Top Forums Shell Programming and Scripting Bash to goto specific line/function and start processing if user response is yes Post 302998062 by cmccabe on Wednesday 24th of May 2017 02:19:19 PM
Old 05-24-2017
Throws an unexpected ;; on the mv line in # move folder to backup. Removing the ;; does allow the scrip[t to execute but with the same results (processes too quickly). Did I misunderstand or do something else? Thank you very much Smilie.

Code:
 ...
...
...
...
run() {
    printf "\n\n"
    printf "All folders have been analyzed, are ready for import, and archieved, are there runs to be analyzed?  Y/N "; read match_choice
     case "$match_choice" in
        [yY]) execute; break;;
       [nN]) remove; printf "Goodbye! "; sleep 2 && exit;;
    esac
}
  execute() {
# extract folder for variable filename
filename=$(awk 'ENDFILE {line=$0} FNR<NR && line ~ $1' /home/cmccabe/medex.logs/folder.log /home/cmccabe/medex.logs/analysis.log)
 
 backup() {
# move folder to backup
mv -v /home/cmccabe/Desktop/NGS/API/$filename /media/cmccabe/"My Book Western Digital"/ClinicalRuns; run; break;;
}
 identifier() {
# associate name with 20x low coverage file
            cd /home/cmccabe/Desktop/NGS/API/$filename/lowcoverage/20x
            /home/cmccabe/Desktop/NGS/scripts/associate.sh $file
# associate name with 20x gene percent file
            cd /home/cmccabe/Desktop/NGS/API/$filename/panel/20x/percent
            /home/cmccabe/Desktop/NGS/scripts/associate.sh $file
# associate name with vcf file
            cd /home/cmccabe/Desktop/NGS/API/$filename/vcf/panel/annovar
            /home/cmccabe/Desktop/NGS/scripts/associate.sh $file
}
 move() {
# move specific folders to MedexPatients on medex CIFS share
mkdir -p /home/cmccabe/medex/MedexPatients/$filename
rsync -av --exclude='/home/cmccabe/Desktop/NGS/API/$filename/bedtools' 
 # move to GenePerecent on CIFS share medex
rsync -av /home/cmccabe/Desktop/NGS/API/$filename/panel/20x/percent/*.txt /home/cmccabe/medex/GenePercent
 # move to Quality Metrics
rsync -av /home/cmccabe/Desktop/NGS/API/$filename/pdf/*.txt /home/cmccabe/medex/QualityMetrics
}
 additional() {
    printf "\n\n"
    printf "Are there additional files to be analyzed?  Y/N "; read match_choice
     case "$match_choice" in
        [yY]) menu; break;;
        [nN]) identifier; move; printf "Select folders and files from "/home/cmccabe/Desktop/NGS/API/$filename" have been moved to MedexPatients on medex as well as to the import folders, the folder will now be achieved "; backup; break;;
    esac
}
 while true; do
    read -p "Do you want to get coverage of a specific gene, genes, or panel?" yn
    case $yn in
        [Yy]* ) menu; break;;
        [Nn]* ) move; break;;
        * ) echo "Please answer yes or no.";;
    esac
done
}


Last edited by cmccabe; 05-24-2017 at 03:20 PM.. Reason: added details
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read the value from a specific line and column BASH

Hi All, I have the same problem as the one posted in https://www.unix.com/shell-programming-scripting/96097-how-read-value-specific-line-column-csh-variable.html but I'm using bash. Can anyone tell me how I have to modify the code to make it bash compatible? eval `awk 'NR==3{print "set... (5 Replies)
Discussion started by: f_o_555
5 Replies

2. Shell Programming and Scripting

BASH - set specific user variable via string operators

Apologies for the utter triviality of this question, but we all have to start somewhere! I've also tried searching but this question is pretty vague so I didn't (a) really know what to search for or (b) get many relevant hits to what I did search for. Anyway, I'm in the process of self-teaching... (1 Reply)
Discussion started by: u5j84
1 Replies

3. UNIX for Advanced & Expert Users

Appending # to the start of specific line in a properties file

Hi, I have the following file, ABC.txt: ABC=123 DEF=234 FGH=345 Based on my validation and conditional processing it is observed that i need to comment or append # before DEF=234 so the same file ABC.txt should look as follows ABC=123 #DEF=234 FGH=345 Sorry if its a... (6 Replies)
Discussion started by: mihirvora16
6 Replies

4. Shell Programming and Scripting

Put a # in start of a specific line of a file

Hello Guys Please let me know how to solve the below issue I have a file like below drop table R1416.ABC1 cascade constraints; drop table R1416.ABC2 cascade constraints; drop table R1416.ABC3 cascade constraints; drop table R1416.ABC4 cascade constraints; drop table R1416.ABC5... (7 Replies)
Discussion started by: Pratik4891
7 Replies

5. Red Hat

User (Profile) Specific Start Menu for RHEL 6.1 using KDE 4.3.4

I installed RHEL 6.1 with KDE 4.3.4 using LDAP on a PC and have now the problem to specifiy a user/Profile specific start menu. I have used already the kmenuedit tool and tailored for one user a specific menu, successfully. I changed as an example the konsole submenu. The kmenuedit was... (0 Replies)
Discussion started by: Gromit
0 Replies

6. Shell Programming and Scripting

Bash - Appending to specific line in file

I'm working on a personal project, a multiplication quiz script for my kids. In it, the user's performance will be recorded and written to a file. After they've played it a little while, it will start to focus more on the ones that give them the most trouble-- that take a long time to answer or... (4 Replies)
Discussion started by: treesloth
4 Replies

7. Shell Programming and Scripting

Looping structure to make up for lack of bash GOTO

Hello, I am re-processing some files when a specific condition is met. The condition is read from the filename. Since files may need to be re-processed a number of times before they no longer meet the condition, I need to know when to stop re-processing. I am having trouble visualizing the... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

8. Solaris

Limit bash/sh user's access to a specific directory

Hello Team, I have Solaris 10 u6 I have a user test1 using bash that belong to the group staff. I would like to restrict this user to navigate only in his home directory and his subfolders but not not move out to other directories. How can I do it ? Thanks in advance (1 Reply)
Discussion started by: csierra
1 Replies

9. Shell Programming and Scripting

Bash function to suppress warning message for specific text and display prompt

In the below bash function multiple variants are input and stored in a variable $variant, and each is written to an out file at c:/Users/cmccabe/Desktop/Python27/out.txt stored on a separate line. # enter variant phox2b() { printf "\n\n" printf "What is the id of the patient getting... (0 Replies)
Discussion started by: cmccabe
0 Replies
ATF-SH(1)						    BSD General Commands Manual 						 ATF-SH(1)

NAME
atf-sh [-s shell] -- interpreter for shell-based test programs SYNOPSIS
atf-sh script DESCRIPTION
atf-sh is an interpreter that runs the test program given in script after loading the atf-sh(3) library. atf-sh is not a real interpreter though: it is just a wrapper around the system-wide shell defined by ATF_SHELL. atf-sh executes the inter- preter, loads the atf-sh(3) library and then runs the script. You must consider atf-sh to be a POSIX shell by default and thus should not use any non-standard extensions. The following options are available: -s shell Specifies the shell to use instead of the value provided by ATF_SHELL. ENVIRONMENT
ATF_LIBEXECDIR Overrides the builtin directory where atf-sh is located. Should not be overridden other than for testing purposes. ATF_PKGDATADIR Overrides the builtin directory where libatf-sh.subr is located. Should not be overridden other than for testing purposes. ATF_SHELL Path to the system shell to be used in the generated scripts. Scripts must not rely on this variable being set to select a specific interpreter. EXAMPLES
Scripts using atf-sh(3) should start with: #! /usr/bin/env atf-sh Alternatively, if you want to explicitly choose a shell interpreter, you cannot rely on env(1) to find atf-sh. Instead, you have to hardcode the path to atf-sh in the script and then use the -s option afterwards as a single parameter: #! /path/to/bin/atf-sh -s/bin/bash ENVIRONMENT
ATF_SHELL Path to the system shell to be used in the generated scripts. SEE ALSO
atf-sh(3) BSD
September 27, 2014 BSD
All times are GMT -4. The time now is 11:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy