How to print a file, excluding comments and blank lines, using grep/sed? August 10, 2023 by Tarik With grep: grep -v '^\s*$\|^\s*\#' temp On OSX / BSD systems: grep -Ev '^\s*$|^\s*\#' temp