nick8967
Posts: 114
Joined: Fri Mar 25, 2016 11:02 pm

what does cd $cwd do?

Thu Oct 17, 2019 2:14 pm

What this command does?

Code: Select all

cd $cwd

User avatar
B.Goode
Posts: 8987
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

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

Thu Oct 17, 2019 2:24 pm

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.
Last edited by B.Goode on Fri Oct 18, 2019 9:42 am, edited 1 time in total.

gkreidl
Posts: 6138
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: what does cd $cwd do?

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).
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

deepo
Posts: 258
Joined: Sun Dec 30, 2018 8:36 pm

Re: what does cd $cwd do?

Fri Oct 18, 2019 9:15 am

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

User avatar
rpdom
Posts: 15588
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: what does cd $cwd do?

Fri Oct 18, 2019 9:24 am

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?

User avatar
PeterO
Posts: 5142
Joined: Sun Jul 22, 2012 4:14 pm

Re: what does cd $cwd do?

Fri Oct 18, 2019 11:02 am

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
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “Beginners”