Score:0

cd with variable not working

cn flag

I am trying to assign a directory name to a variable and use that variable to create and change the directory.

dir_name='tmp'
mkdir $dir_name
cd $dir_name

How to change directory?

enter image description here

Score:1
tr flag

Executing bash test.sh or ./test.sh creates a child bash process to execute your script, with a separate working directory.

You can instead use source test.sh or the shorter equivalent . test.sh to run the script in the existing bash instance and environment.

Score:0
gb flag

I think it works. I followed the following steps.

user@ubuntu2004:~$ dirname="snap"
user@ubuntu2004:~$ mkdir $dirname
user@ubuntu2004:~$ cd $dirname
user@ubuntu2004:~/snap$ 
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.