Question: Facing issues in making a bash script work
gravatar for adnan.haider.ra
4.5 years ago by
adnan.haider.ra10 wrote:

I'm new to Bash scripting. My script intended role is to access a provided path and then apply some software (RTG - Real time Genomics) commands on the data provided in that path. However, when i try to execute the bash from CLI, it gives me following error 

> ERROR:There were invalid input file paths

The path I have provided in the script is accurate. That is, In the original directory, where the program 'RTG' resides, I have made folders accordingly like /data/reads/NA19240 and placed both *_1.fastq and *_2.fastq files inside NA19240.

Here is the script,

    for left_fastq in /data/reads/NA19240/*_1.fastq; do
         lane_id=$(basename ${left_fastq/_1.fastq})
         rtg format -f fastq -q sanger -o ${lane_id} -l ${left_fastq} -r ${right_fastq} --sam-rg "@RG\tID:${lane_id}\tSM:NA19240\tPL:ILLUMINA"

I have tried many work arounds but still not being able to bypass this error. I will be really grateful if you guys can help me fixing this problem. Thanks 

Here is the link for RTG Program,


linux bash • 1.2k views
ADD COMMENTlink modified 4.5 years ago • written 4.5 years ago by adnan.haider.ra10

run your script with the following line:

set -eux

That way you can easily see what's going wrong, always use set -eu

ADD REPLYlink modified 6 months ago by RamRS27k • written 4.5 years ago by Michael Dondrup47k
gravatar for Tej Sowpati
4.5 years ago by
Tej Sowpati250
Tej Sowpati250 wrote:

As far as I can see, there are several syntax errors in your script. Also, I assume you are trying to replace _1.fastq with _2.fastq to get your right fastq file? The syntax you used simply appends _2.fastq, does not substitute. Instead, a simpler although longer approach is as follows.

Step 1: Store your base fastq file names in a file

$ ls /data/reads/NA19240/*_1.fastq | perl -pe 's/_1.fastq//' > file_list

Step 2: Use the following script instead

for lane_id in `cat file_list`; do
    rtg format -f fastq -q sanger -o $lane_id -l $left_fastq -r $right_fastq --sam-rg "Blah Blah"

What you are essentially doing is having a list of base names, from which you will create your left and right files to run the command. Let me know if this works.



ADD COMMENTlink modified 6 months ago by RamRS27k • written 4.5 years ago by Tej Sowpati250
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1268 users visited in the last hour