Per qualche motivo, non posso usare bash
per creare il mio script, l'unico modo per farlo è con ash
, ho questo script di risponditore automatico di sms, ogni risposta deve essere al massimo 160 chacters lungo, assomiglia a questo:Come utilizzare la matrice nella cenere?
#!/bin/sh
reply="this is a reply message that contains so many words so I have to split it to some parts"
array="${reply:0:5} ${reply:5:5} ${reply:10:5} ${reply:15:5} ${reply:20:5}"
for i in $array
do
echo "send sms with the message: $i"
done
ma finisce così:
send sms with the message: this
send sms with the message: is
send sms with the message: a
send sms with the message: reply
send sms with the message: mess
send sms with the message: age
send sms with the message: t
Quello che voglio è qualcosa di simile:
send sms with the message: this
send sms with the message: is a
send sms with the message: reply
send sms with the message: messa
send sms with the message: ge th
send sms with the message: at co
send sms with the message: ntain
Quindi si divide per il numero di caratteri invece di dividere per parole, come posso farlo?
Grazie compagno, questo davvero mi aiuta: D – Lin