The grammar structure しかない can be added directly to the dictionary form of verbs to express that you have no choice but to do something (usually against your will, or when giving up on other options).
やるしかないね。
We’ll just have to do it (We have no other choice).
待つしかない。
I’ll have to wait.
電車が止まったから、歩くしかない。
The train stopped, so I have no choice but to walk.
Comparison: Choice vs. No Choice
It’s worth comparing the two different usages of しか. Notice how the meaning drastically changes depending on whether it is attached to a noun (meaning “only”) or a verb (meaning “no choice but to”).
オンラインでしか買い物しない。
I will only shop online [a deliberate choice].
オンラインで買い物するしかない。
I have no choice but to shop online [e.g., because you live too far from physical shops].
Formal Synonyms (JLPT N3/N2)
While しかない is used heavily in spoken Japanese, you will frequently see its more formal equivalents on the JLPT and in written text: ほかない (or ほかはない) and よりほかない. They connect to the dictionary form of the verb in the exact same way and carry the exact same “no choice but to” meaning.