Append vs Truncate
suggest changeTruncate \>
- Create specified file if it does not exist.
- Truncate (remove file’s content)
- Write to file
$ echo "first line" > /tmp/lines
$ echo "second line" > /tmp/lines
$ cat /tmp/lines
second line
Append >>
- Create specified file if it does not exist.
- Append file (writing at end of file).
# Overwrite existing file
$ echo "first line" > /tmp/lines
# Append a second line
$ echo "second line" >> /tmp/lines
$ cat /tmp/lines
first line
second line
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents