Bash get last line from a variable June 5, 2023 by Tarik An easy way to do this is to use tail: echo "$STRING" | tail -n1