Handy Dandy Cheatsheets!!
Check for number of arguments in bash
Wed, 01/17/2007 - 11:49 — sandip# 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
looping through an array with the for loop in bash
Wed, 01/17/2007 - 11:40 — sandipVALUES=(
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
Mon, 01/01/2007 - 17:39 — sandipTo 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
Sat, 12/23/2006 - 00:57 — sandipIf 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&qu ot;); ?>
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
Wed, 11/08/2006 - 15:09 — sandipRegenerate 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