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

ls

Add the following flags to modify search conditions:

  • -R = recursive list
  • -a = list all
  • -s = show file size
  • -l = show with details
ls | grep "<file/directory name>"

Find 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
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)