Showing posts with label Unix Commands. Show all posts
Showing posts with label Unix Commands. Show all posts

Thursday, August 25, 2011

Finding and deleting old log files

Occassionally you need to clean up some disk space. The quickest and easiest thing to do is often to look for log files that have been rolled by some other process.

For Example:
find . -name *.log.5 -exec /bin/rm '{}' \;
Of course, you need to understand the naming convention of your logs.  Here's a quick example of finding and removing files with a date appended to the original log name.  This command will remove all the log files for the first 9 days of August 2011.

find . -name *.log.2011-08-0* -exec /bin/rm '{}' \;

Monday, March 9, 2009

Ctrl-S in vi hangs my edit session

Sometimes I'm a bit stubborn and continue to work around an issue even though I know there must be a better way. Here's a great example: Working in vi, every now and again, I find myself hitting Ctrl-S when I want to save (Ctrl-S is a windows shortcut for Save for those that don't know...) And when you do that vi gets very unhappy. in fact, it seems to stop responding to all commands, and the only way I was ever able to "fix" my mistake was to close my connection to the server, and log back in. Then I would need to delete the .swp file vi creates when you are in an edit session, and then I could go back in and make all those changes over again (because, of course, I couldn't really save it...) I've been doing this sporadically, as needed, for the better part of 3 years. Today I got fed up and a quick google search (less than a minute) turned up a solution. Ctrl-Q will apparently put vi back in its place and accepting cryptic orders from me again.

Sunday, October 12, 2008

Searching for all the files containing a string

Recursively search all files from the current directory down, ignoring case: grep -ir search_string .
Recursively search all files from the current directory down, ignoring case, and only get the file listing: grep -irl search_string .