# Check for proper number of command line args.
EXPECTED_ARGS=1
E_BADARGS=65
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` {arg}"
exit $E_BADARGS
fi
Cheatsheet
Handy Dandy Cheatsheets!!
Check for number of arguments in bash
Submitted by sandip on Wed, 01/17/2007 - 11:49looping through an array with the for loop in bash
Submitted by sandip on Wed, 01/17/2007 - 11:40VALUES=(
value1
value2
value3
...
valueN
)
# Alternately:
#VALUES=("value1" "value2" "value3" "..." "valueN")
for ((i=0; i<${#VALUES[@]}; i++))
do
echo ${VALUES[$i]}
done
Extract individual files from an RPM
Submitted by sandip on Mon, 01/01/2007 - 17:39To extract an individual file from an rpm package without installing the rpm:
-
Use rpm2cpio or rpm -qpl to list files and full paths in the package:
$ rpm2cpio <package_name> | cpio -t
Use rpm2cpio to extract a file. Run this command from /tmp or elsewhere in order to avoid overwriting any current system files.
This creates the full path in the current directory and extracts the file specified.
$ rpm2cpio <package_name> | cpio -iv --make-directories <full-file-path>
To extract everything to the current directory:
$ rpm2cpio <package_name> | cpio -ivd
»
- sandip's blog
- Login or register to post comments
Load your PHP pages faster with GZip compression
Submitted by sandip on Sat, 12/23/2006 - 00:57If you have heavy pages with lots of images and text, you can greatly improve its' performance by dynamically compressing the page with php.
Put the below code in the header of each php page.
<? ob_start("ob_gzhandler"); ?>
It automatically gzips the page for browsers that support it.
This could also be set in the php.ini file instead, so all php pages are automatically compressed without having to add the above code in each and every php page.
In php.ini add the below code:
output_handler = ob_gzhandler
»
- sandip's blog
- Login or register to post comments
- Read more
Sendmail config regeneration
Submitted by sandip on Wed, 11/08/2006 - 15:09Regenerate sendmail config:
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Regenerate access file:
# makemap hash /etc/mail/access.db < /etc/mail/access
Generate new aliases:
# newaliases
»
- sandip's blog
- Login or register to post comments