Jenkins World

Sunday, 28 June 2020

Create array in loop from number of arguments

You can use the += operator to append to an array.

args=()
for i in "$@"; do
    args+=("$i")
done
echo "${args[@]}"

from : https://stackoverflow.com/questions/15420790/create-array-in-loop-from-number-of-arguments
Posted by Ryoko at 00:34
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

Ryoko
View my complete profile

Blog Archive

  • ▼  2020 (15)
    • ►  July (2)
    • ▼  June (9)
      • How do I make curl ignore the proxy?
      • Replace one substring for another string in shell ...
      • Loop through an array of strings in Bash?
      • In Bash, how can I check if a string begins with s...
      • Print array elements on separate lines in Bash?
      • Create array in loop from number of arguments
      • Run bash command on jenkins pipeline
      • Is there a better way to write this null check, an...
      • Check if a file exists in jenkins pipeline
    • ►  May (3)
    • ►  March (1)
Awesome Inc. theme. Powered by Blogger.