pipe output to append to a text file
I would like to run a command that appends it's output to an existing text file. If I try:
command > file.text it will overwrite file.text - how do I get it to append this file rather than overwrite? Dave |
>>
command >> file.txt Cool |
Thanks again...!
Dave |
You're welcome ;)
Cool |
the command(s) I like this to work for, doesn't
Quote:
Code:
# head /var/log/messages > messages-01.txt output from 'head' is being overwritten. It is not being appended. any ideas why? alternatively, is there a number of lines for cat (or another display util) to output, like tail has? Code:
# tail -n 100 /var/log/messages > text.txt Thanks, Landis. |
Quote:
overwrite the content added previously with the head > command. Unsure why that would not work for you. What distro are you using and what shell? Code:
echo $SHELL Maybe try switching to another shell will help but I can't say I've ever see >> not append. Quote:
Code:
man cat quite ugly and I suspect less efficient than tail. In any case you would still be using >> to append, correct? These commands meet your requirements when I tested them (Again using the bash shell) Code:
head -n 5 /var/log/messages > text.txt to use tail instead of head and then maybe forget to add the second > character?? Easy to do ;) Hope that helps, Tim |
All times are GMT -5. The time now is 06:01 AM. |