Bash: Nth word in a string

Posted by Nicolas Raoul on Stack Overflow See other posts from Stack Overflow or by Nicolas Raoul
Published on 2010-06-09T12:10:31Z Indexed on 2010/06/09 12:12 UTC
Read the original article Hit count: 172

Filed under:

In bash, I want to get the Nth word of a string.

For instance:

  • STRING="one two three four"
  • N=3
  • Result: "three"

What bash command/script could do this?
Thank you!

© Stack Overflow or respective owner

Related posts about bash