|
Clear Arguments By Shifting |
|
|
|
Written by Roceller Alvarez
|
|
Saturday, 26 February 2005 |
|
$ arguments in shell script are not cleared after execution. For
example execute a script “exec.sh arg1″, arg1 is assigned to “$1″. When
you execute “exec.sh” again without the argument, $1 value is retained.
Using “shift” and by assigning argument to a variable will solve this
problem:
# get arguments EXTRA="" until [ $# -eq 0 ] do EXTRA=$EXTRA" "$1 shift; done
Only registered users can write comments. Please login or register. Powered by AkoComment 2.0! |