adspace
Answer Posted / Abhinay Kandrap Kumar
You can use a combination of `cut`, `tr` and `wc` commands to get the last word from a line. The basic idea is to count spaces (or any delimiter) up to the second-last space, then print the rest until the end of the line. Here's an example: `echo "This is a test" | cut -d" " -f$(($(echo "This is a test" | tr " "
| wc -l) - 1))` will give you the last word.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers