0

I have a log file and simple bash script:

echo -e "$date $totalsize $dupsize $per" > log.txt 

But when I execute this script, it write first line of log.txt and show me just last data.

I tried \n but does not working.

How can I write to new line when I execute this script?

onur
  • 5,647
  • 3
  • 23
  • 46

1 Answers1

5

I assume what you mean is that you want to append to the log.txt? In that case, use:

echo -e "$date $totalsize $dupsize $per" >> log.txt

Note the >> which means append.

Using > will create a new file (overwrite it) each time it's run, containing whatever you echo to it.

Jite
  • 4,250
  • 1
  • 17
  • 18
  • @volkanasr Your welcome, glad to help. (Don't forget to accept answer if you feel it's complete.) – Jite Oct 23 '14 at 14:05