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?

2

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.