Using +F will put less in follow mode. This works similar to ‘tail -f’. To stop scrolling, use the interrupt [i.e. Ctrl-C]. Then you’ll get the normal benefits of less (scroll, etc.).
Pressing SHIFT-F will resume the ‘tailling’ [sic].
This is really useful for watching logs while debugging - if you see something interesting scroll past, Ctrl-C to freeze it, then you can use ? with a regex to search back for previous occurrences of the interesting thing.
To explain the cryptic +F syntax: anything you pass after the + is interpreted by less as if you'd pressed those keys while less was running, and Shift-F enables follow mode. So +F just puts less straight into tail mode.
Conversely, you can enable regular command-line options once a less session is already running, by just typing them. For example, I usually run 'less -i' for case-insensitive search, but if I forget the -i, I can just type -i once less has started to disable case sensitivity.
less is actually much more powerful than its standard use as a mere pager would suggest.
less allows you to stop and resume easily, without losing any of the output of your command (useful if you are watching the output of a process as well). Also less doesn't clutter the scrollback of your terminal with output from tail.
Why is it that these are a mystery to most command-line users? Any linux documentation that would be useful to intermediate users, like this article, is scattered across the internet. Even published books don't seem to cut it, and man pages are often too terse and dense to be readable. Is there a thorough, concise linux documentation that I don't know about?
While it's somewhat old, _The Unix Programming Environment_ covers the mindset and a lot of the fundamental tools. _Unix Power Tools_ is another good one. This stuff is particularly novel to people who learned Unix from e.g. Ubuntu + GNOME and worked towards the command line, rather than starting there.
A lot of the tricks listed in the article should be in the man page for sh. I've found a lot reading man pages, but I also use OpenBSD rather than Linux, and its man pages are often noticeably better. (The "we only have a man page to remind you that info is better" pages for GNU utils on Debian are among the worst man pages.) Either way, "apropos" and man pages' SEE ALSO section should help.
I've also found several cool utilities looking at summaries of what was available in the OpenBSD & FreeBSD ports trees, especially in the sysutils and devel categories.
Finally, people who are already using ratpoison/dwm/wmii. as their windowmanager, mpd for playing music, etc. tend to have a common aesthetic, and can usually recommend several other tools. Check out http://onethingwell.org and http://suckless.org for starters.
I make this comment on every one of these posts, but the one I am so glad some beardie committed way back in the dim mists of time is "tsort". Sure, only the linker really needs a topological sort, but pulling it out into a separate executable has saved my bacon on more than one occasion.
It's little gems like that that make Unix bearable.
In what kind of situations do you use topological sort?
I can't think of any scenario where I would use it leading me to think that there are problems I could solve more easily by thinking of them as graph problems.
I've used it to drive a bunch of independent makefiles, when I didn't need an overarching makefile. I've used it to sort dependencies in a simple work queue thing I wrote in the shell. It's not generally all that useful, but being able to grab it and do a quick tsort on paired strings is significantly less painful than writing a Python or Scheme script to do it, and it fits neatly into a pipeline.
I wrote a simple (http://github.com/silentbicycle/wn) to-do graph analyzer for exactly that. I got sick of analyzing "I have to do X, but X needs Y and Z, and Z needs A, and ..." dependency charts. I'm comfortable with BSD make, but sometimes clients give hairy dependency graphs.
Minor gotcha: -- has been morphed to a dash, so be careful to distinguish between one hyphen ('-') and two hyphens (a dash) when typing or copying the command options.
I actually love this feature for most writing. I use -- a lot in emails and in texts and wish it would be expanded to a dash. It's an error in this case, though, especially since copying and pasting the dash gives you one hyphen instead of two.
I especially like the first command "Like top, but for files". Unfortunately, you can't copy&paste this command into your favorite shell, because the apostrophes (') have been replace with some unicode characters (‘ and ’) which look nicer, but are of course unknown to the shell:
watch -d -n 2 ‘df; ls -FlAt;’
The correct command would have been:
watch -d -n 2 'df; ls -FlAt;'
This seems to be yet another annoying automatism of some blog software.
Since watch only display one screen output, it doesn't play nice with something that does a little "hack" to output such as latex. I just figured this out a few minutes ago, and instead, you have to travel through all the output in order to make it run correctly:
A little better than last time...
The author's previous post that is referred to at the top of the post is a ripoff of the top list (at the time) on commandlinefu.com with a very small link only titled "source" at the bottom. He would have done much better to write a short snippet about the the site with a real link and the actual name of the site somewhere in the post. At least this time, it seems not to be a direct copy of some list, and he links to to the site at the top of the post.
That's why I put a cache in front of my blog. The cache is only invalidated when the content of the article changes, or a comment is added. Works really great, page requests take about 10 msec cached, 200 msec uncached (on a shared hosting platform).
The site is responding slow because he mentioned he hosted it on a, I kid you not, SheevaPlug. I'm suprised it didn't take his house down with it in a ball of flames after get HN'd.
It's on my desktop, so it's plenty useful enough for me. And installing it elsewhere isn't exactly rocket science.
I do appreciate the convenience of programs which are installed on every system by default, but that doesn't mean those programs are the only ones which are useful or worth using.
11) Make ‘less’ behave like ‘tail -f’
Using +F will put less in follow mode. This works similar to ‘tail -f’. To stop scrolling, use the interrupt [i.e. Ctrl-C]. Then you’ll get the normal benefits of less (scroll, etc.).Pressing SHIFT-F will resume the ‘tailling’ [sic].
This is really useful for watching logs while debugging - if you see something interesting scroll past, Ctrl-C to freeze it, then you can use ? with a regex to search back for previous occurrences of the interesting thing.
To explain the cryptic +F syntax: anything you pass after the + is interpreted by less as if you'd pressed those keys while less was running, and Shift-F enables follow mode. So +F just puts less straight into tail mode.
Conversely, you can enable regular command-line options once a less session is already running, by just typing them. For example, I usually run 'less -i' for case-insensitive search, but if I forget the -i, I can just type -i once less has started to disable case sensitivity.
less is actually much more powerful than its standard use as a mere pager would suggest.