Search This Blog

Thursday, June 21, 2007

Special shell variables in bash

Bash defines some special variables which are useful while writing shell scripts. They are

$0 = Filename of script
$1 = Positional parameter #1
$2 - $9 = Positional parameters #2 - #9
${10} = Positional parameter #10
$# = Number of positional parameters
"$*" = All the positional parameters (as a single word)[*]
"$@" = All the positional parameters (as separate stings)
${#*} = Number of command line parameters passed to script
${#@} = Number of command line parameters passed to script
$? = Return value
$$ = Process ID (PID) of the script
$- = Flags passed to script (using set)
$_ = Last argument of previous command
$! = Process ID (PID) of last job run in background

[*] Must be quoted, otherwise it defaults to "$@"

Reference :- Appendix B of "Advanced Bash-Scripting guide" by Mendel Cooper, Version 5.0. Debian users can get this document by installing the abs-guide package.

sudo apt-get install abs-guide

The necessary files can be found in /usr/share/doc/abs-guide . However, the abs-guide package contains only the html version of the document. A pdf version can be downloaded from http://www.tldp.org/LDP/abs/abs-guide.pdf .

Tuesday, June 12, 2007

which manpage am I looking at?

Q. which manpage am I looking at?
A.

man -w keyword

gives the filename of the manpage that would be displayed when

man keyword

is entered at the commandline.

To get a list of all plausible manpages use

man -aw keyword

The -w option works for info also.

Q. which info page am I using?
A.

info -w keyword

gives the path of the info file that would have been displayed if the command "info keyword" is used.

Ref :- The manpages of man, info!

Tuesday, June 05, 2007

Stapling paper

When stapling a bunch of letter or a4 sized sheets, staple sizes can be chosen using the following table.

Number of sheets Stack height Staple size
25 1/8'' 1/4''
60 1/4'' 3/8''
90 5/16'' 1/2''
160 9/16'' 3/4''

I assumed the thickness of paper is roughly around 0.1 mm (which might not always be correct!).

Disclaimer: The above info is just a guideline. Use it at your own risk. I am not responsible for any losses that you may incur due to using it.

Followers