write output files with default name
0
0
Entering edit mode
10 months ago
sata72 • 0

I have prepared a shell script file and for the output I want to have a default name, but something is wrong. Can anybody revise this command?

calldir=/profile/variant/input/
base=$(echo $sam | sed "s/.sam.*/_sorted/g")
sam=/profile/variant/input/s5000W_b2.sam
--output $calldir/$(basename $base)_series_name.sam.gz

But in the output the file name didn't change and for all files its:

 _series_name.sam.gz 

I expected this name based on input, I want if the input change the name of output change:

s5000W_b2_series_name.sam.gz 
linux • 971 views
ADD COMMENT
1
Entering edit mode

Try putting the base= command after you define the sam= variable, as $sam is empty when base is defined.

Also, the sed command won't change antthing as there is no pattern ".sam.*" to match in the same variable

ADD REPLY
1
Entering edit mode

You haven't fully explained what you'd like to achieve. You should carefully define your inputs and your outputs. On your example, you modify the value of the $sam variable, but then immediately redeclare it with a new value - which doesn't make sense. I have no idea what the second line is attempting to do. However here is a simple example that takes your $sam and $calldir variables and spits out the value you seem to expect (I think), a few lines in a script called test.sh:

#!/bin/bash
calldir=$1
sam=$2

base=$(basename $sam .sam)
output=$calldir"/"$base"_series_name.sam.gz"

execute it:

./test.sh /profile/variant/input /profile/variant/input/s5000W_b2.sam

output:

/profile/variant/input/s5000W_b2_series_name.sam.gz
ADD REPLY
0
Entering edit mode

What is the 4th line of your command? Why does it start with --output?

ADD REPLY
0
Entering edit mode

the 4th line specify the name of output

ADD REPLY
0
Entering edit mode

i know something is wrong in the line 4th, "$(basename $base) " this section should get the name of input file "s5000W_b2" and create the s5000W_b2_series_call.vcf.gz

ADD REPLY
0
Entering edit mode

Why does it start with a -- though? No commands start with a hyphen.

ADD REPLY

Login before adding your answer.

Traffic: 1617 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6