Tuesday, May 7, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 429  / 2 Years ago, mon, august 8, 2022, 2:16:57

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


More From » bash

 Answers
1

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.


[#1136] Wednesday, August 10, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tinchir

Total Points: 300
Total Questions: 116
Total Answers: 119

Location: American Samoa
Member since Sun, Jan 17, 2021
3 Years ago
tinchir questions
Tue, Sep 14, 21, 23:11, 3 Years ago
Mon, Dec 19, 22, 13:00, 1 Year ago
Sat, Feb 5, 22, 11:36, 2 Years ago
Wed, May 19, 21, 15:53, 3 Years ago
;