How to get the last word from a line in Unix file?
Answer / 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 |
What is architecture of unix operating system?
How do you sort in unix?
What is .profile unix?
What is unix inode?
unix command how to dispaly no of records in oracle?
How to create a blank file in unix?
Explain the following statement, “it is not advisable to use root as the default login.”
What is $# in unix?
What does shebang mean in unix?
What are hidden files in unix?
What are the three major components of any unix system?
Is windows built on unix?