1

Suppose I need a script, which removes a few specific arguments from the argument list and echo the rest. For instance:

The script is myscript.bash and the arguments to remove are b and e.

> myscript.bash a b c d e f
a c d f
> myscript.bash a b c
a c
> myscript.bash b e

How would you write such a script ?

Michael
  • 41,026
  • 70
  • 193
  • 341
  • It sounds nice. Please show what you tried so we can suggest or help wherever you found some problems. – fedorqui Sep 24 '13 at 09:28

1 Answers1

2

I would recommend using case to accomplish this and then echo -n to put the parameters on the same line. You can get all the arguments with $@. Borrowing the example from this post.

for var in "$@"
do
  case $var in
   "a") echo -n $var ;;
   "b") ;;
   [...]
  esac
done
nwinkler
  • 52,665
  • 21
  • 154
  • 168
cete3
  • 647
  • 6
  • 19