Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to append text

Status
Not open for further replies.

jrp

Technical User
Feb 27, 2000
9
0
0
US
Hi. I'm trying to do a log file.
I want to append information at the end of a text file with new information using the console (well, actually using SSI).
Imagine I have a .txt file with IP adresses and time. I want to add my adress and current time to the end of that file, so the administrator knows where and when I came from (of course I want to do a lot more, but with the info on this example I can figure out the rest:) )
How can I do that? what is the console command for doing that?
 
echo "this is some text" >>filename.txt

That should do it.

brendanc@icehouse.net
 
try something like: date >> log_file, where log_file is your log-file. Ip-address can be extracted from ifconfig or /etc/hosts depending on how amny interfaces you have...
try:

grep HOSTNAME /etc/hosts | awk {'print $1'} >> log_file

of course thats just one out of 6.023*10^23 possible solutions...

regards
chenn
 
If you are trying to make your own log file you can simply open the vi or emacs editor using the command vi filename or emacs filename and create the file that way. Make sure that you know the vi or emacs commands to edit and exit before you open the editors. If you are worried about your Sys Admin knowing when you log on and from what terminal, she or he should have a user log file that records this information every time you log on, which is only accessable by him/her.
 
Consider using the mail command. It's not very fancy, but it's easy, it keeps track of who sent what when, it's on every system and the receiver can edit it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top