Skip to main content
Solved

Are some limitations of using tee functions?

  • Mar 11, 2025 3:21 AM UTC
  • 3 replies
  • 97 views

Pawel Kwiatkowski

E.g. I would like use subshell like $(date). Is it possible?

Best answer by Brendan Dalpe

Did a little digging on this. The native function does not spawn a shell, so subshells are not supported.

However, you can customize your tee function to start a new bash shell which will allow you to run a subshell command as you want.

354_55509e803f5540de97053b69ff067279.png

The file is written as expected:

354_fe05d02dec424ea9967aac3883bd55a7.png

Note: You might not see file timestamp rotation because we're keeping that shell open unless it exits for some reason. Just keep that in mind as you're building out the pipeline.

View original

3 replies

Hi @Pawel Kwiatkowski, can you describe the outcome you are trying to achieve? You should be able to use a subshell if the interpreter supports it.


Pawel Kwiatkowski

Hello @Brendan Dalpe
I would like redirect output to a log, eg. /tmp/file_$(date "+%d%h%g").log
When I was using this in the tee fun is not working as expected.

I was trying using '-a' arg but also is not working.


Did a little digging on this. The native function does not spawn a shell, so subshells are not supported.

However, you can customize your tee function to start a new bash shell which will allow you to run a subshell command as you want.

354_55509e803f5540de97053b69ff067279.png

The file is written as expected:

354_fe05d02dec424ea9967aac3883bd55a7.png

Note: You might not see file timestamp rotation because we're keeping that shell open unless it exits for some reason. Just keep that in mind as you're building out the pipeline.