how to compare strings in zsh script 1

how to compare strings in zsh script



for arg do
   i=$(( i + 1 ))

   if [ "$i" -lt "$argn" ]; then
       set -- "$@" ssh -t "$arg"
       set -- "$@" "/pathtofile/$arg/log.log"

command "$@"

Here is what the above code is Doing:
1. It takes the arguments passed to the script and stores them in the variable argn.
2. It then loops through the arguments and shifts them to the left.
3. It then checks if the current argument is the last one. If it is, it appends the path to the log file to the end of the argument list.
4. If it is not the last argument, it appends the ssh command to the argument list.
5. Finally, it executes the command.

The above script can be executed as follows:

$ ./ host1 host2 host3

Similar Posts