[Techtalk] anyone know of a simple text viewer?

Akkana Peck akkana at shallowsky.com
Fri Jul 19 14:54:03 UTC 2019


> Miriam English wrote:
> > I often need to quickly look through the text files in a directory
> > without the need to edit them.

> for f in *.txt ; do leafpad "$f" ; done
> 
> This will loop through all the text files in a directory, one by one. Each
> time I press CTRL-Q to close the current window the next file opens another
> window. It's not exactly what I was looking for, but it is close.
> 
> Anybody know a simpler solution? Preferably one that opens files in the same
> window, one after another, and which when closed quits viewing any further
> files.

Well, I'm a commandline girl so I usually just do something like
less *.txt
which shows each file in the current terminal window.
Admittedly, less has an annoying habit of exiting if you type q
to get out of the current file, so you have to use :n to jump to
the next file. It's a little friendlier to use the same shell loop
you quoted above:

for f in *.txt ; do less "$f" ; done

Less is so much faster than opening a GUI window for each file
(is part of why I like commandline tools).

If you want it in a separate window, so (as you mention) you can
close the window to quit viewing any more files, you could open it
in another terminal:

xterm -e 'for f in .??* ; do less "$f" ; done'

(or use your favorite terminal if not xterm).

But I guess I'm not entirely clear what your goals are. What
improvements were you looking for over the leafpad solution?
Faster? Better UI for scrolling through the file?

        ...Akkana



More information about the Techtalk mailing list