Chris Nizzardini, Salt Lake City Utah, Web Developer Specializing in LAMP+Ajax Since 2006

My Blog

Here is my awesome blog. You can find information on programming, linux, documentation, tips for code and database optimization, my thoughts and rants, and whatever else I feel like sharing. Feel free to contribute to the blog by posting comments and asking questions.
Linux

linux using the cat command to append files together

Log rotate recently rotated my logs a little to early so now webalizer is only displaying statistics for the last two days. After changing logrotat to run once a month instead of weekly I wanted to “repair” my apache log files. I always forget how to use the cat command so it became the perfect candidate for a quick article.

file1 – beginning text.
file2 – end text.

cat file1 file2 > newfile

You don’t have to create a new file. You can just append file1 to file2, but I chose this method just incase I messed something up. Here’s exactly what I did: cat access.log.1 access.log > test and once I verified the test file looked good I did a mv test access.log so now I have one giant log file. I then forced webalizer to run and everything looks good now. Since I’m on it, I actually had to copy access.log to access.log.1 to finally get webalizer to see everything I wanted. I forced webalizer to run by executing the /usr/bin/webalizer command on my debian system.

Related posts:

  1. WaitForExit method, running command line args in c#, and other hacks
  2. Get active directory ldap attributes from the command line with ldifde
  3. setup an easy ftp server on debian 3.1 linux

One Response to “linux using the cat command to append files together”

  1. Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specifically the last part :) I care for such info a lot. I was looking for this certain info for a very long time. Thank you and best of luck.

Leave a Reply