Posts Tagged ‘linux’

Handy Script to Clean Up Corefiles.

Handy Script to Clean Up Corefiles.

Create a file called rmcores(the author calls it handle-cores) with the following in it:

USAGE=”$0 ”

if [ $# != 2 ] ; then
echo $USAGE

echo Deleting…
find $1 -name core -atime 7 -print -type f -exec rm {} \;

echo e-mailing
for name in `find $1 -name core -exec ls -l {} \; | cut -c16-24`
echo $name
cat $2 | mail $name

And have a cron job run it every so often.

Converting all files in a directory to lowercase.

Converting all files in a directory to lowercase.

# lowerit
# convert all file names in the current directory to lower case
# only operates on plain files–does not change the name of directories
# will ask for verification before overwriting an existing file
for x in `ls`
if [ ! -f $x ]; then
lc=`echo $x | tr ‘[A-Z]’ ‘[a-z]’`
if [ $lc != $x ]; then
mv -i $x $lc

Wow. That’s a long script. I wouldn’t write a script to do that; instead, I would use this command:

for i in * ; do [ -f $i ] && mv -i $i `echo $i | tr ‘[A-Z]’ ‘[a-z]’`;

on the command line.

Speeding up your hard drive

Get faster file transfer by using 32-bit transfers on your hard drive in Linux Machines

Just add the line:

hdparm -c3 /dev/hdX

to a bootup script.

If you use SuSE or other distros based on SYS V,


should work for you.

This enables 32-bit transfer on your hard drive. On some systems it can improve transfer performance by 75%.

To test your performance gain, type:

hdparm -t -T /dev/hdX

Script to view those compressed HowTos.

Script to view those compressed HOWTOs.

From a newbie to another, here is a short script that eases looking for and viewing howto documents. My howto’s are in /usr/doc/faq/howto/ and are gzipped. The file names are XXX-HOWTO.gz, XXX being the subject. I created the following script called “howto” in the /usr/local/sbin directory:

if [ “$1” = “” ]; then
ls /usr/doc/faq/howto | less
gunzip -c /usr/doc/faq/howto/$1-HOWTO.gz | less

When called without argument, it displays a directory of the available howto’s. Then when entered with the first part of the file name (before the hyphen) as an argument, it unzips (keeping the original intact) then displays the document.
For instance, to view the Serial-HOWTO.gz document, enter:

$ howto Serial

1 2 3 4 5

Content Protected Using Blog Protector By: PcDrome. & GeekyCube.