Reading filenames into an array

前端 未结 5 2130
青春惊慌失措
青春惊慌失措 2020-11-29 18:30

I want to get a list of files and then read the results into an array where each array element corresponds to a file name. Is this possible?

5条回答
  •  旧时难觅i
    2020-11-29 19:03

    Try this,

    path="" # could set to any absolute path
    declare -a array=( "${path}"/* )
    

    I'm assuming you'll pull out the unwanted stuff from the list later.

提交回复
热议问题