Score:0

How to assign a path variable on a bash file?

tm flag

I need to create a bash file that automatically makes new directories and assign some of them to a variable. I can make folder without problems but when I test variables with echo the console return me nothing:

#!/bin/bash

mkdir ~/Scrivania/TEST2/Salmonella_enterica
mkdir ~/Scrivania/TEST2/Salmonella_enterica/NCBI
mkdir ~/Scrivania/TEST2/Salmonella_enterica/NCBI/vs2
mkdir ~/Scrivania/TEST2/Salmonella_enterica/NCBI/vs2/Annotation
mkdir ~/Scrivania/TEST2/Salmonella_enterica/NCBI/vs2/Sequence
mkdir ~/Scrivania/TEST2/Salmonella_enterica/NCBI/vs2/Sequence/Chromosomes
mkdir ~/Scrivania/TEST2/Salmonella_enterica/NCBI/vs2/Sequence/WholeGenomeFasta
CHR="~/Scrivania/TEST2/Salmonella_enterica/NCBI/vs2/Sequence/Chromosomes"
ANN="~/Scrivania/TEST2/Salmonella_enterica/NCBI/vs2/Annotation"
WGF="~/Scrivania/TEST2/Salmonella_enterica/NCBI/vs2/Sequence/WholeGenomeFasta"
cd ~/Scrivania/TEST2

When I try to assign the variable directly from terminal it works perfectly (copy-pasted from the script, so no typo), it just does nothing when i execute the .sh, except creating folders. Thanks, i'm sure it's a stupid question but I never used bash files before.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.