Hone

Lessons · Terminal · . 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/b
Three levels down.
ls ..
The folder above is a, and it contains b.
cd ../..
Up two.
pwd
Ends in /demo.

Your turn

List the folder above this one.

ls 

The trap

Typing cd .. as cd. or cd . . and wondering why nothing happened. Two dots, no space, is one name.

Practise . and .. on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.