Tag Archives: output

spew: For testing purposes

I’m suddenly inundated with testing a half-dozen new laptops here, so I don’t have a lot of time for writing up posts.

I did have a moment this morning to check out spew, which I believe is in the Debian repos, in Fedora and in their derivatives, but surprisingly not in Arch.


spew is a tool for testing I/O performance and generating workloads for those tests. What you see above is spew’s text-based interface, writing out a quick 128Mb file and checking the read-write stats.

By default spew works mostly in a CLI-fashion, as opposed to the whole-screen approach you see above. We haven’t seen too many I/O tools for the console — not counting iotop, which was the first one I could think of offhand — so it’s probably a good idea to keep this one around.

The next time I get an ancient laptop and a wicked-slow hard drive, I’m going to hunt down spew and see what it can tell me. Next time. 😉

echo: And an inescapable fragment of history

After much internal debate, I decided to include echo in this august parade. echo hardly does anything, but I use it so much that it would be a glaring omission if I didn’t include it.

You probably already know what echo is for: It outputs a string of text. That’s the first line of the man page, after all.

kmandla@6m47421: ~$ echo Hello world.
Hello world.

And now you’ve seen all that echo does … mostly. 😉

Like any good tool, it has a few things you can customize. For starters there is an -n flag, which prevents echo from breaking to a new line when it finishes. In other words:

kmandla@6m47421: ~$ echo -n Hello world.
Hello world.kmandla@6m47421: ~$ 

echo can also do some funny things, if you allow it with the -e flag. The man page has a full list, but for example, line feeds are possible. A line feed is not a newline, as this should show:

kmandla@6m47421: ~$ echo -e "Hello \fworld."

And line feeds are not carriage returns, as this should show:

kmandla@6m47421: ~$ echo -e "Hello there, \rworld."

If you remember computers from way, waaay back, you probably already knew the difference. If you don’t it might help to imagine a printer head moving across a page. Line feeds advance the paper without moving the head, and carriage returns bring the printer head back to the starting edge without advancing the paper. Put both of them together and you have a newline. And of course, all of this evolved from the days of manual typewriters, when your printer was 168cm tall and took coffee breaks twice a day.

I’ll leave it to you to explore all the subtleties of echo; there aren’t many, but it is a utility that you can use on a daily basis and still not see every option. And of course, echo is part of the world-famous coreutils suite. 🙂

tee: More magic from coreutils

I have reached a point where I actively look forward to programs from coreutils, because I know they’re going to be good.

tee is no exception; like so much of what’s in coreutils, it is deceptively simple.


tee splits output two ways: once to STDOUT, and once to a file. So probably 90 percent of the time on this blog, when I’ve shown you something like this:

shuf -n1 /usr/share/dict/cracklib-small > test.txt ; cat test.txt

I could have done this instead:

shuf -n1 /usr/share/dict/cracklib-small | tee test.txt

and gotten both the file I was after and the output to show, without relying on two commands (and arguably abusing cat).

tee doesn’t just redirect to one file; you can list as many as you like.

kmandla@jk7h5f1 ~ $ echo "Test" | tee test-{01..10}.txt
kmandla@jk7h5f1 ~ $ ls test-*
test-01.txt  test-03.txt  test-05.txt  test-07.txt  test-09.txt
test-02.txt  test-04.txt  test-06.txt  test-08.txt  test-10.txt

Knowing that there will be identical output means you can also use tee to write to a file, but wrangle the output in some fashion. This is where you should be thinking about sort or sed or whatever, to create a record of the output, then an adjusted version.

tee takes flags for appending files rather than clobbering them, and as an added note, if you insert a hyphen as a file name, you’ll get double STDOUT. In other words,

kmandla@jk7h5f1 ~ $ echo "Test" | tee -

If you didn’t know about tee until now, it should open a few doors for you. Or at least, make a few things easier in your command-line adventures. 😉

tcat: Just quickly, because it’s fun

I wanted to squeeze tcat in today, not just because I have a string of task managers that will otherwise monopolize the week, but also because it’s fun.


tcat saves you the stress of splicing date and cat, and working out the funky sequence to divide them with a tab character.

The help pages promise that tcat does absolutely nothing other than stream data through, and prepend it with a time stamp. So far, it has kept that promise for me.

tcat will let you wrangle the stamp format, in the same way you would might use the date command alone. Together that allows you to pipe any kind of output you like, through tcat and get the same information, just stamped.

Nifty, huh? 😀

splitvt: Under the most dire of circumstances

Between tmux and screen, there’s really not much space for upstart splitscreen console tools, unless they can do things really, really well.

splitvt is really, really not that tool.


That’s the prettiest, cleanest results I could get from splitvt, although I admit I hardly tried beyond the first few console tools that came to mind.

Yes, splitvt can run two console apps in the same frame. And yes, you can spin it up with two very different applications, and get both of them going with reasonable fidelity.

But anything outside of the simplest, most basic output gets sickeningly mangled, like a ten-car horrorcrash, or a drunken prom queen turned loose on a makeup counter in an abandoned department store.

htop came out looking like Van Gogh’s The Starry Night. Midnight Commander was a gob of scrambled eggs sliding off a plate. Don’t even ask me about elinks. I don’t like to think about it. 😯 😥

And splitvt is clearly intended for non-interactive programs. I find splitvt traps you in the upper bracket, meaning any input intended for the lower half is effectively ignored.

There’s some sort of “command mode” for splitvt, which I found by accident. If you hit CTRL+O and then enter a question mark, you’ll get a brief list of commands. From there you can adjust the property boundary, copy and paste (supposedly) or lock the screen. Other tips are listed.

But I’ve seen enough. I know it’s not fair to pick on a program that’s beyond its freshness date, and it may be that when splitvt was in its prime, it was neck-and-neck with the best that screen or tmux could offer.

But these days, with tmux leading the pack featurewise, and screen coming out of retirement to do battle with the usurper … splitvt is easy to dismiss. Try it, but only under the most dire of circumstances. 😐

script: That terminal session recorder you always wanted

I wasn’t going to include script in these little adventures, but owe a day’s worth of programs after skipping a day yesterday, and script isn’t terribly difficult to cover.

It is difficult to show though, since you don’t really have any guarantee that what I’m doing is really working, if I can only show a static image. But script is part of util-linux, and it’s been around apparently since 3.0BSD, which translates to around 1979 and the same time the users command was added. So it’s probably available to you. 😯

Try this at home then, and see if you are as astounded as I was when I first saw it happen.

script -t 2> man.timing -a man.session

You should get an acknowledgement that says, “Script started, file is man.session”. Next,

man script

You can peruse that for a little bit. When you’re done, exit your man page reader and enter this:


And the output is “Script done, file is man.session”.

So what good is that? Well, do this next:

scriptreplay man.timing man.session

And you get a perfectly timed session replayed as you like. And yes, it works with ncurses and fullscreen apps, and as far as I can tell, there doesn’t seem to be a limit on terminal dimensions (except perhaps on replay … I don’t expect it can cram a huge recording into a tiny window frame).

It’s funny, there are a baker’s dozen of console recording tools out there in the world, some working, some not — some even hotwired into cloud services and offering automatic uploads and infinite replays. 😐

I’m sure they all are fine and dandy. And yet, from the depths of util-linux comes a simple, straightforward terminal recorder that’s been around … well, since forever. :mrgreen:

spark: Itty bitty graphs for your terminal emulator

I have to make the distinction this time, that spark probably won’t work for you in a virtual console. I believe it can only do this in a terminal emulator:


Unless I’m mistaken, there’s not much chance to get that working in a virtual console, because the fonts will display as unidentified characters. I think. It will depend. (A framebuffer terminal emulator should be fine though, so long as your font supports it.)

Regardless, spark does something interesting and kind of cool, and if you’re clever you should be able to find a way to integrate that into something else.

spark probably won’t see much more development; not that the creator is lax, but rather that I don’t know how much more it could do. There are dozens of ideas for how to use spark on the github wiki, but I think spark might have reached its logical conclusion.

A well-earned round of applause in that case then. 😀

lilypond: That gray area

I am very much on the fence when it comes to including lilypond on this list.

As I understand it, lilypond — the program — just converts text-based sheet music into a visual format (I believe the home page calls it “engraved”) not unlike what LaTeX does … although I know very little about that either.

So the net effect of lilypond is this:


Text-based coding for sheet music converted into pdf format, without much of an interface or interaction.

That doesn’t discount it as a text-based application, any more than imagemagick or even inkscape, or some other tools that follow the same style.

That does drop it into a gray area though, where the benefit is in the output, and not the interface.

So is it a command-line application? Is it a true-blue text-only program?

I’m not going to fight through this one. I humbly submit that it does its job, interface or no interface, and if you need to draw some sort of line in the sand to reinforce an us-and-them mentality … then you’ve overlooked the real beauty of software like this — making life easier, and more beautiful.

ionice: It’s nice to be nice to the nice

I don’t use ionice as much as I should. I know better, but it’s always an afterthought to me. Mea culpa.

ionice works where nice doesn’t. The best example I can think of is laggy behavior on disk transfers, like copying a giant file from one place to another.

You can nice the copy process all you want, but you’ll probably still sense some lag, because you’re just devoting more processor priority to cp, which isn’t where the problem lies.

To that end, next time you are waiting for a big file to decrypt, or you’re splitting volumes in the background, try. …

sudo ionice -c3 -p###

where ### is the process number for the copy process or gnupg or split or whatever. Class 3 sets it to “idle,” meaning so long as nothing else needs disk access, this process can do as it wants. Otherwise, it takes a back seat.

I think I first learned about this from jdong’s website, years ago. The page is still there, and so is a gimmick to switch your whole shell process — and therefore everything subsequent that you start from there — to idle process. Take a peek; it’s a short but useful read.

ionice is part of util-linux. 😉

bwm-ng: Flexible, smart and pretty

bwm-ng comes along at just the right time. We haven’t seen any network monitors in quite a while.

Of course, I have to make the obligatory offhand remark that there are hundreds — literally hundreds — of network monitors and visualizers out there.

I’ve listed a few of them on this site, but I’ve barely scratched the surface.

But, seeing as we are in the “B” section now, bwm-ng has good timing.


Rather like VU meters, on stereo equipment from a long time ago.

That’s not the default display, by the way. That is with the “curses2” flag, which I am sure you can hunt down on your own.

bwm-ng will also output to html or csv, and has options to make sure your data can be converted to another format, be it spreadsheet or browser or whatever.


And best of all? It’s not just a network monitor, it can also watch disk access, and output in the same style — VU meters, or whatever.

Pretty nifty, if you ask me.