Bash script jumping too quickly to the next command - crash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash script jumping too quickly to the next command - crash
# 15  
Old 05-24-2016
You posted code which you didn't actually run. Naturally I spotted an error which didn't actually happen. In the future, post your code very exactly: Word for word, letter for letter, keystroke for keystroke. The quoting for that line is seriously wonky no matter how you cut it though. Try

Code:
echo -e "#SampleID\tBarcodeSequence\tLinkerPrimerSequence\tInputFileName\t${custom}\tDescription" > "${metadata}/metadata.tsv"

And once again, run it with set -x so we can see what actually happens. Without that we're only wild guessing.

Last edited by Corona688; 05-24-2016 at 02:43 PM..
# 16  
Old 05-24-2016
Hi, iam really sorry about the mis-communication.
I really appreciate your help.
This is the line and its set -x output;


Code:
[CFIA-ACIA+tremblaye@biocomp-0-12 ~]$ echo -e "#SampleID\tBarcodeSequence\tLinkerPrimerSequence\tInputFileName\t${custom}\tDescription" > "${metadata}/metadata.tsv"
+ echo -e '#SampleID\tBarcodeSequence\tLinkerPrimerSequence\tInputFileName\tTrapType\tLure\tCollectionDate\tProvince\tCity\tDescription'
[

# 17  
Old 05-24-2016
How about the lines after it?
# 18  
Old 05-24-2016
Code:
#create Metadata file for QIIME
[CFIA-ACIA+tremblaye@biocomp-0-9 ~]$ custom=$(echo "${customFields[@]}" | sed -e 's/ /\\t/g')
++ echo TrapType Lure CollectionDate Province City
++ sed -e 's/ /\\t/g'
+ custom='TrapType\tLure\tCollectionDate\tProvince\tCity'
[CFIA-ACIA+tremblaye@biocomp-0-9 ~]$ echo -e "#SampleID\tBarcodeSequence\tLinkerPrimerSeq
> 
> for g in $(find "$trimmed" -type f | grep "
> do
>   name=$(basename "$g")
>   nameNoExt="
>   #create array: a=(1 2 3 4)
>   #show
>   #t="${nameNoExt//-/ }"
>   #params=("${nam
>   #echo "${params[@]}"
>   param1=$(cut <<< "$na
>   param2=$(cut <<< "$nameNoExt" -d "-" -f 
>   param3=$(cut <<< "$nameNoExt" 
> 
>   tempLine=$(cat "$barcode" | grep "$param1" | grep "$param2" | grep "$param3")
>   echo "$tempLine" | awk -v fileName="$name" -v sampleName="$its" -F $'\t' 'BEGIN {OFS = FS} {print $1, $3, $4, fileName, $6, $7, $8, $9, 
> done
> 
> 
> ##########

---------- Post updated at 04:23 PM ---------- Previous update was at 04:22 PM ----------

ok, it seems like from my black box some info is lost with copy/âste.

The command I ran was this
Code:
#create Metadata file for QIIME
custom=$(echo "${customFields[@]}" | sed -e 's/ /\\t/g') #add custom
echo -e "#SampleID\tBarcodeSequence\tLinkerPrimerSequence\tInputFileName\t${custom}\tDescription" > "${metadata}/metadata.tsv"

for g in $(find "$trimmed" -type f | grep "fasta" | grep -v "scrap") # -v -> exclude
do
  name=$(basename "$g")
  nameNoExt="${name%.*}"
  #create array: a=(1 2 3 4)
  #show content of array: echo "${a[@]}"
  #t="${nameNoExt//-/ }"
  #params=("${nameNoExt//-/ }") #${string//substring/replacement}
  #echo "${params[@]}"
  param1=$(cut <<< "$nameNoExt" -d "-" -f 1) #equals $(echo "$nameNoExt" | cut -d "-" -f 1)
  param2=$(cut <<< "$nameNoExt" -d "-" -f 2)
  param3=$(cut <<< "$nameNoExt" -d "-" -f 3 | sed -e 's/Run//') #only keep the number of the run

  tempLine=$(cat "$barcode" | grep "$param1" | grep "$param2" | grep "$param3")
  echo "$tempLine" | awk -v fileName="$name" -v sampleName="$its" -F $'\t' 'BEGIN {OFS = FS} {print $1, $3, $4, fileName, $6, $7, $8, $9, $10, $1"-"sampleName}' >> "${metadata}/metadata.tsv"
done


#######################
#                     #

# 19  
Old 05-24-2016
...and what does it show with set -x ? One or the other by itself is not useful! We need both!
# 20  
Old 05-25-2016
The command was this:
Code:
#create Metadata file for QIIME
custom=$(echo "${customFields[@]}" | sed -e 's/ /\\t/g') #add custom
echo -e "#SampleID\tBarcodeSequence\tLinkerPrimerSequence\tInputFileName\t${custom}\tDescription" > "${metadata}/metadata.tsv"

for g in $(find "$trimmed" -type f | grep "fasta" | grep -v "scrap") # -v -> exclude
do
  name=$(basename "$g")
  nameNoExt="${name%.*}"
  #create array: a=(1 2 3 4)
  #show content of array: echo "${a[@]}"
  #t="${nameNoExt//-/ }"
  #params=("${nameNoExt//-/ }") #${string//substring/replacement}
  #echo "${params[@]}"
  param1=$(cut <<< "$nameNoExt" -d "-" -f 1) #equals $(echo "$nameNoExt" | cut -d "-" -f 1)
  param2=$(cut <<< "$nameNoExt" -d "-" -f 2)
  param3=$(cut <<< "$nameNoExt" -d "-" -f 3 | sed -e 's/Run//') #only keep the number of the run

  tempLine=$(cat "$barcode" | grep "$param1" | grep "$param2" | grep "$param3")
  echo "$tempLine" | awk -v fileName="$name" -v sampleName="$its" -F $'\t' 'BEGIN {OFS = FS} {print $1, $3, $4, fileName, $6, $7, $8, $9, $10, $1"-"sampleName}' >> "${metadata}/metadata.tsv"
done

The ouput, with set -x was that:
Code:
custom=$(echo "${customFields[@]}" | sed -e 's/ /\\t/g')
++ echo TrapType Lure CollectionDate Province City
++ sed -e 's/ /\\t/g'
+ custom='TrapType\tLure\tCollectionDate\tProvince\tCity'
[CFIA-ACIA+tremblaye@biocomp-0-9 ~]$ echo -e "#SampleID\tBarcodeSequence\tLinkerPrimerSeq
> 
> for g in $(find "$trimmed" -type f | grep "
> do
>   name=$(basename "$g")
>   nameNoExt="
>   #create array: a=(1 2 3 4)
>   #show
>   #t="${nameNoExt//-/ }"
>   #params=("${nam
>   #echo "${params[@]}"
>   param1=$(cut <<< "$na
>   param2=$(cut <<< "$nameNoExt" -d "-" -f 
>   param3=$(cut <<< "$nameNoExt" 
> 
>   tempLine=$(cat "$barcode" | grep "$param1" | grep "$param2" | grep "$param3")
>   echo "$tempLine" | awk -v fileName="$name" -v sampleName="$its" -F $'\t' 'BEGIN {OFS = FS} {print $1, $3, $4, fileName, $6, $7, $8, $9, 
> done
> 
> 
> ##########

# 21  
Old 05-25-2016
How exactly are you running this code? I see prompts and such appearing in it, it doesn't look like its being run from a shell script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need bash script to use a sed command as a variable

I need to be able to use a sed command as a variable in a bash script. I have the sed command that almost works the way I want it. the command is sed -n '/inet/,/}/p' config.boot This gets me this result: inet 192.168.1.245 } I need to get the IP address into a variable so I... (9 Replies)
Discussion started by: edlentz
9 Replies

2. Shell Programming and Scripting

New bash menu printing errors but closes too quickly

I am beginning to write a new version of the bash menu below. The previous version worked great and now when I start the updated bash it opens and a some lines print in the terminal and it closes quickly. I know there are errors but how can I see them or fix them, I tried set -x with the same... (12 Replies)
Discussion started by: cmccabe
12 Replies

3. Shell Programming and Scripting

How to ignore error in command in bash script?

Hello, i have bash script where im cycling some command for different lines in external file. example: while read domain;do nslookupout=$(nslookup -type=ns $domain) || true another commands done < filenamewithdomains i added: || true after the command in belief it will just skip... (6 Replies)
Discussion started by: postcd
6 Replies

4. Shell Programming and Scripting

BASH SCRIPT of LS command

I need help in writing a BASH SCRIPT of ls command. for example: $ ./do_ls.sh files f1.txt f2.jpeg f3.doc $ ./do_ls.sh dirs folder1 folder2 folder3 My attempt: #!/bin/bash # if test $# -d file then echo $dirs else (3 Replies)
Discussion started by: above8k
3 Replies

5. Solaris

jumping from one line to another

Hi, Thanks (10 Replies)
Discussion started by: rocky1954
10 Replies

6. Shell Programming and Scripting

Piping output from a command into bash script

Hi all. I am using procmail to deliver an email to a script I am developing. Procmail delivers the email to the script on standard input. I imagine this is the same as piping input from a command into the script. Hence I've been testing my script by running echo 'test' | sms-autosend-backup.sh ... (2 Replies)
Discussion started by: akindo
2 Replies

7. Shell Programming and Scripting

work area directory jumping script?

hi all, Ive been trying to find some way of doing this for ages but i have is a shell script that activates a python search and there it no tab completion. more familliar with tcsh at the moment but i'm a newbe. i was trying to make an easy way to browse to a list of working directories. ... (0 Replies)
Discussion started by: jvan
0 Replies

8. UNIX for Dummies Questions & Answers

need solution for this quickly. please quickly.

Write a nawk script that will produce the following report: ***FIRST QUARTERLY REPORT*** ***CAMPAIGN 2004 CONTRIBUTIONS*** ------------------------------------------------------------------------- NAME PHONE Jan | ... (5 Replies)
Discussion started by: p.palakj.shah
5 Replies

9. Shell Programming and Scripting

script to loop and check jumping seq.

Hi, Normally, I will manually to use "ll" command to list the following file from \FILE\CACHE\ directory and check the jump seq. Can I write a script to loop or/and check jump seq file (if jumped seq and show "missing seq no" message for me) -rw-rw----+ 1 user develop 14012 Sep 4... (1 Reply)
Discussion started by: happyv
1 Replies

10. Shell Programming and Scripting

Linux Os Crash Script

How can I simulate a Linux OS crash without damaging the OS? I am performing an os watchdog test that sends out an alert once the timer expires. (1 Reply)
Discussion started by: cstovall
1 Replies
Login or Register to Ask a Question