Thursday, 22 December 2016

Shell Script 8: redirect symbol > and >> < and <<

'>' overwrites the file after it while '>>' append content to the file after it.

jtony@genoa:~/learn/shell$ cat test.txt
Red Pepper

jtony@genoa:~/learn/shell$ echo "Green Peper" > test.txt
jtony@genoa:~/learn/shell$ cat test.txt
Green Peper

jtony@genoa:~/learn/shell$ echo "Yellow Peper" >> test.txt
jtony@genoa:~/learn/shell$ cat test.txt
Green Peper
Yellow Peper

You can also take inputs from files for commands by using the less-than symbol (<).
jtony@genoa:~/learn/shell$ cat < test
Green Peper
Yellow Peper


No comments:

Post a Comment