Sick Linux Commands
blog.urfix.com
blog.urfix.com
11) Make ‘less’ behave like ‘tail -f’
less +F somelogfile
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 myfile.log &ERROR # filter out any line that doesn't match the regexp ERROR F # capital f enters follow mode
Now you're tailing a log with a custom grep, which is retroactive on history as well.
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.
It's little gems like that that make Unix bearable.
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.
The simplest fix is to enclose your command lines with the "<code>" HTML tag.
A good WordPress companion for blog featuring lots of command-lines and code is Alex Gorbatchev's SyntaxHighlighter: http://alexgorbatchev.com/SyntaxHighlighter . Several WordPress plugins are available. I personally use SyntaxHighlighter Evolved: http://wordpress.org/extend/plugins/syntaxhighlighter
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.
watch -n 120 'lynx -dump http://news.ycombinator.com' tr ‘’“” \'\'\"\" | shHaven't tried it myself.
watch latex --halt-on-error hw.tex | tailhttp://webcache.googleusercontent.com/search?q=cache:DVyf69P...
cat /etc/issue
A better method is using the lsb_release tool:
lsb_release -a
If that's not installed: cat /etc/lsb-release
may work.It's yet another blog that fails to do the most basic thing in the web: delivering small static content quickly.
http://blog.urfix.com.nyud.net/25-sick-linux-commands/
And a text-only version cached by Google:
http://webcache.googleusercontent.com/search?q=cache:DVyf69P...
Try utimer instead:
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.
You install random convenience utilities on all of your production servers?
I didn't think so.