navigation
Where am I , and what is around me
Those two questions cover half of terminal work The other half is getting back
Absolute and relative
A path beginning with / is absolute
Anything else is relative to the current directory
. is here , .. is one level up
cd /var/log
cd ..
pwd
pwd prints the current directory
When a script misbehaves, print it first
Pull a path apart
basename /var/log/syslog
dirname /var/log/syslog
Output:
syslog
/var/log
Useful when a loop hands you full paths and you only want the filename
Find things
find /var/log -name '*.log' -type f
find walks a tree
-name matches a pattern
-type f keeps files only
I have watched people grep -r through a whole home directory for a filename
find exists so you do not do that
Globs
ls *.log
ls file?.txt
* matches any string , ? matches one character
The shell expands these before the command sees them
Quoting the pattern stops that expansion
Next
Files get created and destroyed in 03 files
Posted