4 ms·
Linux has hundreds of them, in the various bin directories. Many are interesting. This shell snippet lists all the directories in $PATH, using less, so you can
by vram22 9y ago
Linux has hundreds of them, in the various bin directories. Many are interesting.
This shell snippet lists all the directories in $PATH, using less, so you can page through them:
for dir in `echo $PATH | sed 's/:/ /g'`
do
echo Listing dir: $dir
ls -l $dir | nl
done | less
I came across the watch command recently, which seems useful, and wrote something like it in Python:
A Python version of the Linux watch command:
https://jugad2.blogspot.in/2018/05/a-python-version-of-linux-watch-command.html https://jugad2.blogspot.in/2018/05/a-python-version-of-linux...
I've also been writing Python versions of some other Linux commands, and will post about them here some time later.
Also, for saving (and then viewing) man pages (about commands or other topics), without the formatting characters (such as ^H), on some Linux distros, I find this useful:
m, a Unix shell utility to save cleaned-up man pages as text:
https://jugad2.blogspot.in/2017/03/m-unix-shell-utility-to-save-cleaned-up.html https://jugad2.blogspot.in/2017/03/m-unix-shell-utility-to-s...
- laumars 9y ago> Also, for saving (and then viewing) man pages (about commands or other topics), without the formatting characters (such as ^H), on some Linux distros, I find this useful: ^H is one of the two backspace characters (the other being ^?) depending on which VT standard you're configured to use. So you shouldn't really need a dedicate script to do that as it's just a problem between your pseudo-TTY (Linux console) and your terminal emulator (PuTTY / iTerm / xterm / etc). Thankfully both are easily configurable. However without knowing which terminal emulator you're using I couldn't walk you throw configuring that. In terms of the TTY; you can change the backspace character via the `stty` command: stty erase [hit backspace on your keyboard] Another thought is it might be a case that the TTY is largely configured correctly already but you're overwriting your environmental variables with non-standard values (eg the $TERM var with a value that differs from the actual terminal you're using) which is causing the pager (`less` / `more` etc. `man` will use this for the paging) to break the standard your terminal is expecting. But either way, this is definitely a configuration problem rather than something that should be fixed with additional parsing scripts.
- vram22 9y agoThanks for your inputs. A few comments: I first created that script called m years ago on some Unix boxes that I was using. Could have been HP-UX or other version. And I've used it over the years on many Unix and Linux versions that I worked on. It could be that in some cases, the script is needed due to a tty or TERM or other configuration issue. But I'm pretty sure that I've had the need for it (to remove those control characters) on at least some systems where such config was okay. I know this because, while I do tweak env. var., stty and other settings now and then, I do not always (need to) do so, and have still found control chars [1] in the man output, even when redirecting to file. That is why I created the script, because when working on a C, Python or any other project where I need to read man pages, I often like to redirect the man output to a file (in my ~/man dir) and then read them using vi/vim. [1] See what I say in that post (about m) about nroff and troff. Also, I do know about stty, have used it for years, although there is less need for it these days. Used to do a lot of tweaking and experimenting with the erase option (for which, BTW, instead of backspace key in your example, we can also write a literal ^h, i.e. caret, then letter h), intr option, onlcr, ocrnl and others. Used to be good fun and sometimes frustrating too, because docs for this areas were somewhat lacking then.
- vram22 9y agoAlso see the man page for the col command, which is used in my m script: http://man7.org/linux/man-pages/man1/col.1.html http://man7.org/linux/man-pages/man1/col.1.html
- laumars 9y agoI don't make a habit of commenting on shell scripts what I haven't first read. But thank you all the same. I used to use 'col' alot to resolve the tabs Vs spaces problem with different actors imposing different preferences in their source code. It's a handy tool but often overlooked.
- vram22 9y ago>I don't make a habit of commenting on shell scripts what I haven't first read. But thank you all the same. Sorry, I should have added "if you haven't already read it", in my earlier comment. >I used to use 'col' alot to resolve the tabs Vs spaces problem with different actors imposing different preferences in their source code. It's a handy tool but often overlooked. Interesting, I may not have noticed or known about the tabs option of col. Cool. Seems it is like the entab program in an edition of the K&R C book. https://www.google.co.in/search?q=kernighan+and+ritchie+c+programming+language+entab+program https://www.google.co.in/search?q=kernighan+and+ritchie+c+pr...