6 ms·
With less, you can use m<letter> to mark the current position and '<letter> to go to a marked position. h will show you lots of useful help.
by evincarofautumn 12y ago
With less, you can use m<letter> to mark the current position and '<letter> to go to a marked position. h will show you lots of useful help.
- jimktrains2 12y agoGP isn't meaning it like that, they mean being able to add some spaces so that the next log entries stand out for quick visual identification as you're making changes and reloading the application.
- toddkaufmann 12y agoUse '/' (search) to enter a regexp to match a pattern on that line, and it will be highlighted.
- lgas 12y agoThis has nothing to do with what is being discussed in this subthread.
- teraflop 12y agoSure it does. If your log lines are distinct (e.g. they have timestamps or unique IDs) then you can use less's search highlighting to provide a visual marker for a specific line, similar to what you can do by manually inserting a bunch of blank lines on the console. This trick doesn't work if your log file has a bunch of identical lines and you want to keep an eye on their rate, though.
- shawabawa3 12y agoimagine the scenario: "I want to see everything that happens in a single request" Enter method: 1. Press enter a bunch of times 2. Reload browser 3. Press enter a bunch of times and scroll up Your method: 1. Search for last line in output to highlight it? 2. Reload page 3. Try and figure out where stuff starts and ends with loads of visual noise
- MadcapJake 12y agoless method: 1. ma 2. Reload browser 3. 'a less method with two marks: 1. ma 2. Reload browser 3. mb 4. 'a
- ajanuary 12y agoUnfortunately mark doesn't seem to work while you're following.
- teraflop 12y agoI won't argue that for this specific use case, tail isn't friendlier than less. But the original poster posted a useful tip, and is now getting aggressive downvotes and comments like "This has nothing to do with what is being discussed in this subthread." I think that's unwarranted.
- gojomo 12y agoHaving to remember & type a timestamp has much more mental overhead (planning & memory) than "scan/scroll back to last block of vertical whitespace". That's why suggestions of either named-marks or back-searches aren't considered equally-attractive alternatives to marking the scrollback with a batch of <return>s.
- shangxiao 12y agoA bunch of blank lines is a lot more grokable than timestamps lost in a bunch of text.
- bch 12y agoAn example of some of the vi commands that less(1) has adopted. You can also: * page forward and backward, including using numeric prefixes to indicate a lineno or indicate "repeat 'n' times". * launch vi if less(1) is working on a file (versus (eg) stdout of some process) * search fwd/backward * start examining a new file w/o leaving less(1) * ...
- pjungwir 12y agoJust the other day I was looking for a way to do this in less: yank 10 lines, open a new file, paste the 10 lines, save the file. Is that possible? My Googling last week didn't find a good solution.
- bch 12y agoIf you wanted to grab 10 lines from /var/log/messages, starting at the first line that has "pjungwlr" in it, you could: $ less /var/log/msgs /pjungwlr^M ^G (note line informational line numbers) v (launch vi) [double check your line #s, etc] :d1,. (delete from 1st line, to current line) 10j (go down 10 lines) :d,$ (delete to EOF) :w my_newfile :q
- technofiend 12y agoThis is such a common problem there's a stackoverflow article on it. http://stackoverflow.com/questions/17908555/printing-with-sed-or-awk-a-line-following-a-matching-pattern http://stackoverflow.com/questions/17908555/printing-with-se... (Actually, there's probably more than one despite their really good duplication grooming, but this was the first hit.)
- pjungwir 12y ago`v` was the missing key for me. Looks like it even preserves my position in the file. Thanks!
- kragen 12y agoUsually I `ma|acat > newfile` in less, which saves by default a whole screenfull. There must be a better way to do this in less.