0

I don't know if it's possible,

I would like start a bash script without pipe which write everything to a file and at the same time see the output on the terminal.

So I know how to do that with this command :

ls -l |& tee test.log

How can I create this file directly from a line in my script and not using a pipe ?

Couim
  • 195
  • 2
    What's wrong with using a pipe? – muru Jun 24 '19 at 15:06
  • This script will be used by others persons and I would like to know if it's possible to write a log file automatically without ask the person to use pipe :) – Couim Jun 24 '19 at 15:10
  • Also see: https://unix.stackexchange.com/questions/296322/redirect-script-stderr-stdout-to-a-file-but-keep-stdout-to-tty-as-well – muru Jun 24 '19 at 15:11
  • So are you asking about a script, and not ls? If so then you can modify the script. – ctrl-alt-delor Jun 24 '19 at 15:15
  • I cleaned up the question (grammar etc), but what do you mean by “directly from the file”? – ctrl-alt-delor Jun 24 '19 at 15:17
  • @muru Yes it's a duplication, this is what I wanted – Couim Jun 24 '19 at 15:26
  • @ctrl-alt-delor Sorry I didn't explain myself clearly, I wanted to log stdout in a file and in the prompt at the same time. – Couim Jun 24 '19 at 15:26
  • @Couim Sorry but what do you mean by “directly from the file”? I know that you want to direct stdout to a file and the terminal, this was explained earlier in the question. Also don't respond with a comment, instead fix the question. – ctrl-alt-delor Jun 24 '19 at 18:54
  • Do you want the output in the prompt, that is to change the prompt string? So that after all subsequent commands, the string is displayed? – ctrl-alt-delor Jun 24 '19 at 18:55
  • @ctrl-alt-delor Indeed, I read my post again and it's not clear :) So I edited my post : I want to create a log file without any pipe, so basically "directly from the file" meant that I wanted to do that "directly from the script" :) – Couim Jun 25 '19 at 07:57
  • I am still confused as to what you are trying to do. “Somehow it seems to fill my head with ideas--only I don't exactly know what they are! However, you are trying to log something: that's clear, at any rate.” – ctrl-alt-delor Jun 25 '19 at 11:14

0 Answers0