0

Script – Purge spam folder

Posted by admin on Jun 18, 2009 in Scripts

#!/bin/bash
#This example is for a linux server using the following directory stucture to store email
#/home/unix-username/mail/domain/email-username/Maildir/.INBOX.spam/(cur | new)
#the following command will find all spam messages system wide over 14 days old and remove them
/usr/bin/find /home/*/mail/*/*/Maildir/.INBOX.spam/*/ -type f -ctime +14 | xargs /bin/rm -f
#-ctime n*24 hours
#-cmin n minutes
#-ctime +7 = > 1 week

Tags: , , , ,

 
0

Script – Avoid argument too long error

Posted by admin on Jun 18, 2009 in Scripts

When removing 10,000’s of files with rm -f * you get an argument too long error.
#### Remove too man files. 
#### First find -name ‘*’ > filelist
#!/bin/bash
for i in $( cat filelist );
do
echo $i
rm -f $i
done
#####
##### Easier way to remove too many files right from command line
#####
ls|xargs rm -f

Tags: , ,

 
0

Script – find and replace

Posted by admin on Jun 18, 2009 in Scripts

#########
#
#  change the same value in all files showen under ls in a directory
# good for mass IP changes
#
##########
#!/bin/bash
for i in $( ls );
do
sed -i ’s/find/replace/g’ $i
done

Tags: , ,

 
0

Script – bash while loop

Posted by admin on Jun 18, 2009 in Scripts

#!/bin/bash
while read line;
do echo “<option>$line</option>” >> cities.out;
done < cities.in
# above processes a text file where a line item might contain spaces
# a for loop that cat’s the file will process each space as a separate item
#!/bin/bash
x=1
while [ $x -le 100 ]
do
  echo “Hello World – $x times”
  x=$(( $x + 1 ))
done

 
0

Script – named.conf.secondary

Posted by admin on Jun 18, 2009 in Scripts

My Notes
#######
#
## Command Line Input – Create single secondary entry
#
#####
#!/bin/bash
# Edit IP variable to equal the IP address of the master name server
IP=10.0.0.1
echo -n “Enter Domain Name: ”
read name
echo “zone \”$name\” { type slave; masters { $IP; }; file \”/var/named/$name.sec\”; };” >> /etc/named.conf.secondary
#######
#  Make Secondary named.conf file
# FROM MASTER named.conf
#######
#!/bin/bash
IP=10.0.0.1
cat /etc/named.conf |grep zone |grep -v “type [...]

Tags: , , ,

Copyright © 2010 BenMcGrail.com All rights reserved.
Hosted by: VitexOnline.com