If someone tells me to 'save the file to $PWD', what does this mean?
Does '$' sign largely used among linux users to represent something?
For your information, I got this phrase from my instruction sheet from basic C++ course that is held in linux lab.
21 Answer
In most shells – sh, bash, csh..., – the $NAME syntax denotes variables (similar to %NAME% in Windows cmd.exe); usually environment variables, but several of them are internal to the shell.
(But note that this convention also sometimes extends to written instructions, where you would be expected to mentally substitute the values when reading the text.)
Similarly, some programming languages – PHP, Perl – also use $name for variable names.
In your example, $PWD is an automatic envvar that expands to the current directory's path:
> cd /etc/modprobe.d
> echo $PWD
/etc/modprobe.dSo to save a file "to $PWD" you wouldn't need to do anything special; trying to open a bare filename with no path already uses the current directory.
If you had been given a different, custom variable, you would have to use getenv("NAME") to obtain its value in a C++ program.
You can use env to see all environment variables, but also check the shell's documentation for a few unusual ones.