How to write to a file in shell script?


Linux uses >> operator to write to a file.

For instance:
If you want to calculate the size of your log directory and want to write it somewhere, then

du -s  /var/log>> filename

Isn't this simply awesome,


Multiple commands
( date +'%Y %m %d %H : %M'; du -s /var/log) >> LogsDirectorySize.txt;

In above sample, we are writing date plus size both. Yes, so simply use semi colon ; to write multiple things.








Enjoy Linux...!!!














0 comments:

Post a Comment