Loop through an array of strings in Bash?

前端 未结 19 3165
情深已故
情深已故 2020-11-22 03:59

I want to write a script that loops through 15 strings (array possibly?) Is that possible?

Something like:

for databaseName in listOfNames
then
  # D         


        
19条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 04:16

    Possible first line of every Bash script/session:

    say() { for line in "${@}" ; do printf "%s\n" "${line}" ; done ; }
    

    Use e.g.:

    $ aa=( 7 -4 -e ) ; say "${aa[@]}"
    7
    -4
    -e
    

    May consider: echo interprets -e as option here

提交回复
热议问题