# To ignore lines that start with #, use this (thanks to Pete's comment): export $(grep -v '^#' .env | xargs) # And if you want to unset all of the variables defined in the file, use this: unset $(grep -v '^#' .env | sed -E 's/(.*)=.*/1/' | xargs)