use tee command to redirect output to a file in a non-existent dir

前端 未结 4 2516
攒了一身酷
攒了一身酷 2021-02-20 02:22

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         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-20 03:10

    mkdir ./new_dir && date | tee ./new_dir/new_file
    

    Since it is tee command, it simultaneously writes both to the new_file and to stdout

提交回复
热议问题