Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
pwd shows where you are in the tree, from / to the current folder. It is built into Bash; there is also a program /usr/bin/pwd with the same options.
The same value is in the variable $PWD, and the previous folder is in $OLDPWD.
Zo schrijf je het
pwd [-LP]Opties 4
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 11
$ als gewone gebruiker# als root (of met sudo)
1Show where you are
pwd /home/studentThe first command to run when you are lost.
2Show the real folder behind a link
With links, the logical and the physical path can be different.
3Use the current folder in a command
tar -czf /tmp/backup-$(basename "$PWD").tar.gz .$PWDis the same aspwd;basenametakes the last part.4Save the folder and come back later in a script
Keeps the script predictable.
5Check you are in the right place before a delete
pwd && lsA two-second check that prevents deleting the wrong files.
6Show the previous folder
echo "$OLDPWD"The folder that
cd -would take you back to.7Print an absolute path of a file in this folder
echo "$(pwd)/config.yaml"Good when a tool needs a full path.
8See the difference between logical and physical
The first is the path you used, the second the real place.
9Show the folder of a process
pwdx $(pgrep -o sshd)pwdxshows the current folder of another process (from /proc/PID/cwd).10Use the program instead of the built-in
/usr/bin/pwd -PSame result; useful in other shells.
11Put the path in the prompt
PS1='[\u@\h \w]\$ '\win the prompt shows the current folder all the time.
Niets past bij dit filter.
Tips om te onthouden
pwd= where am I?pwd -P= where am I really (no links)?