echo -n "##### STATIONS? #######"
read station
awk -v input="$station" '
BEGIN {
n = split(tolower(input), user)
fmt = "%-4s\n"
}
{print}
/stab_site clear/ {
for (i=1; i<=n; i++)
printf fmt, "stab_site" user[i]
exit
}
' ./data > data_2
Let assume user's input: ankr ista
for stations. After the execution of codes, in data file, after the "stab_site clear
" line, user's input is written as follows;
stab_siteankr
stab_siteista
I need to give one space between "stab_site" and "station_ids" in the codes. I also need to write the lines after one space from the beginning of the line as follow;
stab_site ankr
stab_site ista