Monday, June 7, 2010

How to get an absolute value

Some times when we calculating difference we don't want to show the negative value. What we are interested in is only the difference. so here is the command.


prasad@mac:~# absolute_value=-123
prasad@mac:~# echo ${absolute_value#-}
123

You can use this in any shell script.