I want to iterate over a list of arguments in a shell, I know how to do this with
for var in $@
But I want to do it with
for ((i=3; i<=$#; i++))
I need this because the first two arguments will not go into the loop. Does anyone know how to do this? We are waiting for you to help.
cheng
This can help:
for var in "${@:3}"
for more information you can see:
http://www.ibm.com/developerworks/library/l-bash-parameters/index.html
reader_1000 provides a nice bash spell , but if you use an older (or simpler) Bourne shell, you can use creaky ancients (and therefore very portable)
VAR1=$1 VAR2=$2 shift 2 for arg in " $@ " ...
Although this is an old question, there is another way to do this. And perhaps this is what you are asking for.
for(( i=3; i<=$#; i++ )); do echo "parameter: ${!i}" #Notice the exclamation here, not the $ dollar sign. done
Source: https://habr.com/ru/post/898442/More articles:Firefox adds 1px to my submit button - cssiPhone: how can I store UIImage using NSUserDefaults? - iosHow can i get iphone device type? - objective-cRails 3 Nested resource routes inherit parental restrictions; how can I avoid them? - restIs it possible to use komodo editing as git core.editor (i.e. without forking)? - gitDataContractSerializer and dictionary do not work when reading - genericsWhere does the thread go when the future leaves its appearance? - c ++log4j: ERROR Error converting date - javaGo to vim line from relativenumber to - vimNPE with Perf4j and Log4j - javaAll Articles