ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
I'm posting this question here because of the Regexp, if Im in the wrong place please let me know.
The question is simples, can I search inside Less using a RegExp ?
If the answer is yes, how can I make a backsearch for to word to be matched in the same line but in aleatory place with Regexp?
Thanks !
Example: find the word hotmail and john in: John accessed this page: hotmail.com
/pattern
Search forward in the file for the N-th line containing the pattern. N defaults to 1.
The pattern is a regular expression, as recognized by the regular expression library
supplied by your system.
?pattern will search backward.
I don't think regexps are that great at doing the particular kind of search you want though, (John.*hotmail|hotmail.*John) is probably the best you can do (if you know John goes before hotmail you can use just the first half, of course). With grep you can use more than one regexp like this:
This file Im reading is a Log file of about 4gb, some weird problem made the syslog not to rotate the files and now I had to find some information requested by the company high board... using grep is normaly my first choice but in this case trying to quick the process I used the less and ? / to find what I want, of course I didnt hope to get the answer before the time I had to give the information to the board, but this doubt sticked in my head and I came here to ask maybe for a future know how...
btw, this logrotate problem will be my next thread, very strange thing, in old days just syslog was responsible for logging and stuff now Im having many problems trying to figure out who do what in the logging business lol
but already was of good help your answers.
thansk
[ ]'s
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.