34

In linux, how do I do something like

echo 'hello world' > log.txt

but instead of overwriting the contents of log.txt, it appends to the end of of log.txt?

freiheit
  • 14,544
  • 1
  • 47
  • 69
John
  • 7,343
  • 23
  • 63
  • 87

4 Answers4

66
echo 'hello world' >> log.txt
laurent
  • 2,055
  • 16
  • 14
8

Try:

>>

In place of:

>
GregD
  • 8,713
  • 1
  • 24
  • 36
5

In Linux you can also use the useful HERE TAG for multiline append :

cat >> log.txt << EOF
hello word 1
hello word 2
hello word 3
EOF

Linux shell's are more more powerful than windows command prompt! ;)

aleroot
  • 3,180
  • 6
  • 29
  • 37
4

echo 'hello world' >> log.txt

disserman
  • 1,850
  • 2
  • 17
  • 35