I'm writing a shell, others can pass arguments to it, like:
someshell task1 task2 -Daaa=111 -Dbbb=222 task3
In the shell, I can get all the arguments with $@
, which is:
task1 task2 -Daaa=111 -Dbbb=222 task3
Then I want to get all args start with -D
out of the string, and make two strings:
-Daaa=111 -Dbbb=222
and
task1 task2 task3
I'm not familiar with bash, what I can do now is to split the string and check each item, then group them in someway. Which seems a little complex.
If there is any simple way to do this?