Paths and navigation
Navigate safely and read a file whose path contains spaces.
A path starts somewhere
An absolute path begins with /. A relative path starts at the current working directory, shown by pwd. . means the current directory and .. its parent. The lab begins at /home/user; its saved-work contract covers regular files and directories beneath that location.
cd changes the current shell’s directory. Use quotes around paths with spaces: cd 'team notes' passes one directory name. Without quotes Bash passes two arguments. Chain a dependent action with && so it runs only when the directory change succeeds.
Terminal versus script
Terminal commands share a Bash session, including its current directory. Run launches bash /home/user/main.sh as a child of that session. A cd inside the script does not change its parent terminal. Check starts a clean session at /home/user.
Use the supplied files to practise navigation without touching your own computer. The Linux sandbox is not your Mac’s filesystem. Downloading a script copies its text; it does not make virtual paths exist on your device.
pwd
cd 'team notes' && cat './shift.txt'
Put it into practice.
Read `team notes/shift.txt` and print its contents unchanged. Use a relative path from the initial `/home/user` directory. Do not change the supplied file.
See an explained solution
cd 'team notes' || exit 1
cat './shift.txt'
Quoting makes the directory one argument. The failure guard prevents reading an unrelated file if navigation fails.