What's ように being used for at the end of these lyrics?


There's this song I really like called "空がこんなに青いとは" in which there are the
following lyrics:

> 空は教えてくれた  
>  大きい心を持つように  
>  友達の手を放さぬように

I'm kind of confused on how ように is being utilized at the end of the last two
sentences.

I understand the string of lyrics as meaning:

> The sky taught me to have a big heart, and to never let go of a friend's
> hand.

But what is the ように for? From my understanding it's usually used at the end of
a sentence to indicate hope or a wish for something, but I'm not sure if the
nuance's the same here. Could anyone please give me a breakdown of how it's
being used? Thanks in advance!




It's ように used to make an instruction/command/wish. It's used before verbs such
as 願う, 頼む, 命令する, 伝える, 言う and 教える. に is sometimes dropped.

  * 彼に来るよう(に)頼んだ。  
I asked him to come.

  * 音を立ててスープを飲まないよう(に)教えた。  
I taught them not to slurp soup.

  * 黙るよう(に)言って！  
Tell her to shut up!

In your case, the verb (教えてくれた) comes first, which is a common rhetoric device
known as 倒置 (hyperbaton/anastrophe). It's followed by the content of the
teaching.

As you already know, ように is used also at the end of a sentence, and I agree
that this usage is loosely related.

  * ここで待つように。  
Wait here.

  * 大学に合格しますように。  
May I get accepted into college.

It's explained in these definitions:

> #### [ようだ](https://dictionary.goo.ne.jp/word/%E6%A7%98%E3%81%A0/)
>
> **４** （多く「ように」の形で）ある動作・作用の目的・目標である意を表す。「わかりやすくなるように並べかえましょう」
>
> **５** （「ように」の形で）婉曲 (えんきょく) な命令・希望の意を表す。「開始時刻に遅れないように」「今後ともよろしくご指導くださいますように」

