Skip to content

Script output to file: Append -v- Replace

This article was been published more than a year ago. The information may be outdated.

By default, when running a script, the output is shown to you in the command line interface. Most of the time, that is exactly what you want. Some times, though, you are more interested in logging than in real-time data. The solution is to have the output sent to a file.

As an example, imagine the following: You want to see where the traffic to a server ends, so you run a traceroute to find out. Normally, the command would like like this: tracert server.dom

Here’s what you would use to route the output to a text file: tracert server.dom > textfile.txt.

Now, that’s all well and good, until you want to add more logs to the same file. The problem is that a single > will replace the contents of the file in question with the new information. To append, rather than replace, use a double >, like so: tracert server.dom >> textfile.txt.

Be First to Comment

By posting a comment, you consent to our collecting the information you enter. See privacy policy for more information.

This site uses Akismet to reduce spam. Learn how your comment data is processed.