I am trying to use the tee command to redirect output to a file, and I want the file to be created in a dir which is yet to be created.
date | tee new_dir/new_fi
Replace tee with a function that creates the directory for you:
tee
tee() { mkdir -p ${1%/*} && command tee "$@"; }
If you want the function to work when invoked with a simple file name:
tee() { if test "$1" != "${1%/*}"; then mkdir -p ${1%/*}; fi && command tee "$1"; }