Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Shell Script execute without save to temporary variable

Tags:

linux

bash

If I want to execute a command with variables in it, I always have to store the string first in a variable and then can execute it...

Example:

path_fasta="/home/xxx/yyy/zzz/qqq/"
name_fasta="CTA_Mix_DNA.fna"
path_outp"/some/Path/"

temp='find . -maxdepth 1 -not -name '$name_fasta' -not -name letsgo.sh -delete'
$temp

temp=$path_mothur'mothur #set.dir(output='$path_outp');summary.seqs(fasta='$path_fasta''$name_fasta')'
$temp

How do I do this directly without storing it first in temp? Must be easy, but did not find a solution...

like image 569
Michael Avatar asked Sep 08 '26 03:09

Michael


1 Answers

Instead of:

temp='find . -maxdepth 1 -not -name '$name_fasta' -not -name letsgo.sh -delete'
$temp

...just use:

find . -maxdepth 1 -not -name "$name_fasta" -not -name letsgo.sh -delete
like image 130
Brian Cain Avatar answered Sep 09 '26 17:09

Brian Cain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!