I want to add a "-r <remote_host>" option to my ksh script, causing the script to run a script of the same name on the specified remote host. The remote invocation should itself include all the command-line options of the original invocation, less the -r option.
That looks like it's designed exclusively for the example I posted, but I'm looking for a more generic solution. The "-r <remote_host>" text might be anywhere in $@.
---------- Post updated at 09:03 PM ---------- Previous update was at 08:55 PM ----------
That works for the example I posted, but it seems to assume that the text I need to remove is bounded by minus signs. For example, if "-r ..." is the last option, and is followed by arguments, that code doesn't pass the arguments through:
# echo the_script -a -b -r the_remote_host arg1 arg2 | sed 's/-/~-/g' | tr "~" "\n" | egrep -v "\-r" | tr -d "\n"
the_script -a -b
The approach of splitting into multiple lines and using "grep -v" is interesting, though.