Lessons · Terminal · this folder and the one above (. and ..)
. is here, .. is up
Every folder contains two pointers: . means this folder and .. means the one above. They work anywhere a path does.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
../data, ./run.sh, cd ../..: these appear in every README and every script, and they only make sense once the two dots are second nature.
How to think about it
Read a path piece by piece: .. climbs one level, then whatever follows the slash. ./name says 'the one right here', which is how you run a file in this folder.
Worked example
mkdir -p demo/a/b && cd demo/a/bThree levels down.
ls ..The folder above is a, and it contains b.
cd ../..Up two.
pwdEnds in /demo.
Your turn
List the folder above this one.
ls
Try it at a real prompt
The trap
Typing cd .. as cd. or cd . . and wondering why nothing happened. Two dots, no space, is one name.
Now you try
Next in Terminal
Practise this folder and the one above (. and ..) on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.