Contents
File Sizes
Size of all files in a directory
du -h
Size of current directory
du -h -s
Size of top-level directories within current directory
du -h -d 1
Find files
List Files & directories
ls
Add the following flags to modify search conditions:
- -R = recursive list
- -a = list all
- -s = show file size
- -l = show with details
Filter on name
ls | grep "<file/directory name>"
Find String
All files containing a string
grep "<search string">
Add the following flags to modify search conditions:
- -r = recursive list
- -w = only match whole words
- | = use in search string as an OR
For a specific directory or file
grep "<search string>" my/directory/
grep "<search string>" my/directory/myfile.txt
Assign Environment Variables
If you’ve got a list of environment variables in a .env file, this will assign them all to your existing environment:
export $(grep -v '^#' .env | xargs)