Posted by admin on Jun 18, 2009 in
My Notes
Have a file or directory that you can’t delete because there is a space at the end of the file name?
If you try and delete from windows you will get the error message
“Error Deleting File or Folder”
“Cannot delete file: Cannot read from the source file or disk.”
To manipulate these files you need to address their [...]
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: bash, linux, Maildir, purge spam, Scripts
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: bash, linux, Scripts
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: bash, linux, Scripts
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
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: bash, bind, linux, Scripts