Page 1 of 1

what does cd $cwd do?

Posted: Thu Oct 17, 2019 2:14 pm
by nick8967
What this command does?

Code: Select all

cd $cwd

Re: make -j4 command on OpenCV makes RaspberryPi 3 B+ stuck

Posted: Thu Oct 17, 2019 2:24 pm
by B.Goode
nick8967 wrote:
Thu Oct 17, 2019 2:14 pm
What this command does?

Code: Select all

cd $cwd

(No obvious relationship to the substantive question in the thread in which this was originally posted ... )

From the output of

Code: Select all

man cd
cd - Change the shell working directory

$cwd is an environment variable.

Re: what does cd $cwd do?

Posted: Fri Oct 18, 2019 8:50 am
by gkreidl
Nothing!

It means "change directory to current working directory" but this is where you already are (inside a terminal).

Re: what does cd $cwd do?

Posted: Fri Oct 18, 2019 9:15 am
by deepo
gkreidl wrote:
Fri Oct 18, 2019 8:50 am
Nothing!

It means "change directory to current working directory" but this is where you already are (inside a terminal).
Not necessarily true.
$cwd is a variable that I guess the OP found in a script somewhere.
If you are logged in as e.g. pi and are currently in the / folder and then type cd $cwd from a terminal, then that will result in a cd command that will change directory to your home directory, because the $cwd variable is empty.

/Mogens

Re: what does cd $cwd do?

Posted: Fri Oct 18, 2019 9:24 am
by rpdom
gkreidl wrote:
Fri Oct 18, 2019 8:50 am
Nothing!

It means "change directory to current working directory" but this is where you already are (inside a terminal).
Is cwd a shell built-in variable? I know PWD is, but don't think cwd is. Perhaps cwd has been set elsewhere?

Re: what does cd $cwd do?

Posted: Fri Oct 18, 2019 11:02 am
by PeterO
rpdom wrote:
Fri Oct 18, 2019 9:24 am
Is cwd a shell built-in variable? I know PWD is, but don't think cwd is. Perhaps cwd has been set elsewhere?
I will admit to having to check as my first thoughts were that $cwd existed though I was suspicious about $cwd vs $CWD,
$PWD does exist (at least on login shells running bash, but neither $cwd or $CWD exist by default, (AFAICT)
PeterO