- Wicket's Date & Time Components and Client-Server Timezones
- Some useful Java System Properties while starting JVM.
- Jbossws 2.0.1 with JDK 1.6
- Date & Time selection made simple in Wicket
- New Features in Vim 7
- Maven best practices: Use dependency management for multi module projects.
- Prototyping LAMP with WAMP
- Bash shell tricks
Things you didn't know bash could doAre you sure you are squeezing out all, that the bash shell can provide. Presented below are a few obscure things that bash can do, but chances are you may not have heard of them. CompletionNo I am not talking about completing command/file names. I am talking about completing arguments to various commands, completing filenames based on application. This is one of the touted features of 'zsh', but unknown to many is the fact that it is also available in bash. All you need to do is install bash-completion. With bash competion installed you can use the
The feature I find most handy is file-name completion based on the context of the command. e.g. if you
type
Socket Communication
I bet a lot of you haven't heard of this, but bash can indeed perform basic socket communication
via So how to use them, we below I present 2 examples. One to quickly check headers from a HTTP Server. Here is a simple function you can put in your headers() {
server=$1; port=${2:-80}
exec 5<> /dev/tcp/$server/$port
echo -e "HEAD / HTTP/1.0\nHost: ${server}\n\n" >&5
cat <5
exec 5<&-
}
Simply invoke it by Second example is a quick way to check if a port is open or not. You can always use netcat or telnet, but I find this easier. testPort() {
server=$1; port=$2; proto=${3:-tcp}
exec 5<>/dev/$proto/$server/$port
(( $? == 0 )) && exec 5<&-
}
Again invoke it by
Arithmetic Evaluations
Bash can perform arithmetic evaluations. They are much easier to using ((count++)) #increment value of variable 'count' by one.
((total+=current)) # set total = total+current.
((current>max?max=current:max=max)) # ternary expression.
Other neat bash tricks
|
|||