How to get the nth word of a line in Unix?
Answer / Ashish Mani Tiwari
In Unix, you can use a combination of `cut` and `tr` commands to extract the nth word from a given line. The basic idea is to count spaces (or any delimiter) up to `n-1`, 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) - 2))` will give you the last word.
| Is This Answer Correct ? | 0 Yes | 0 No |
command to show the space allocation of files?
What do you mean by the protection fault?
what is wrong with this interactive shell script?
How do I find my unix os version?
Explain how and when a DNS request is solved when a user tries to surf to the site www.abcdeg.in .Assume the user machine uses a local name server and sits on another network other than www.abcdef.in.
What is grep|sort give example?
What does $? Mean in unix?
What is umask in unix?
What is difference between ssh v1 and ssh v2?
following two file are file a file b 110 aab 330 xxl i want the output like file a fileb 110 xxl 330 aab give solution ?
How to perform a system shutdown in unix?
What is inode in unix operating system?