Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Not exactly sure what you mean. It is often best to give an example. As far as grep goes, have a look at the -o option will give you only the text you are looking for and
maybe the -m option which allows you to stop after a particular number of matches.
I am not sure I understand your question. If you know the next word of a particular word is going to be that word, whats the point?
Do you want to know how many times a particular word appears in a text file?
Do you want to know on which line is the next appearance of a particular word?
In my mind there would be know reason for a command that just returns a word that you already know.
For example.. Let stay I have a text file containing all the text above this line.
grep word file.txt
The above command would return all the lines containing the word, therefore giving you some context as to how the word was being used, or where it was in the file.
A word search as your asking can be done in editors like vi and nano. In vi you can use the following command (while in command mode) to find the next "word".
$ cat file
In linux is there a way to find the next word of a particular word of a file.
grep displays entire line of the particular word.
But i want to find only the exact next word of that particular word.is there any command for that.
$ ruby -ne 'puts $_.scan(/find\s+(\w+)/)' file
the
only
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.