shell脚本分割多行字符串
#!/bin/bash
string="I'm\nNed\nNederlander
I'm\nLucky\nDay
I'm\nDusty\nBottoms"
arr=()
while read -r line; do
arr+=("$line")
done <<< "$string"
for val in "${arr[@]}";
do
echo "$val\n"
done
#!/bin/bash
string="I'm\nNed\nNederlander
I'm\nLucky\nDay
I'm\nDusty\nBottoms"
arr=()
while read -r line; do
arr+=("$line")
done <<< "$string"
for val in "${arr[@]}";
do
echo "$val\n"
done