More, less, and a story of typical Unix fossilization
utcc.utoronto.ca
utcc.utoronto.ca
(more does not page if its stdout is not a terminal)
more < /etc/passwd | less
Print lines X-Y to X of a file. :D
sed -ne 'X,Yp' /etc/passwd
I should learn to use sed properly.
<input-file grep stuff
Unless you are concatenating stuff, I see no reason to use cat.Sure I could use "<something.txt grep something", but that requires me to decide to use grep right off the bat, something I hardly ever do. Usually I want to look at it first.
I'm not sure what you mean about -X and mouse scrolling.
For URxvt:
! Ctrl-Shift-A will show alternate screen URxvt.keysym.C-S-A: command:\033[?47h ! Ctrl-Shift-Z will return to regular screen URxvt.keysym.C-S-Z: command:\033[?47l
For XTerm:
! Ctrl-Shift-Z will toggle alternate screen VT100translations: #override \n\ Ctrl Shift <KeyPress> z: set-altscreen(toggle)
Imagine alternative history of UNIX, where NixOS was invented really long time ago, before 'less' was created. Now, imagine we're Mark Nudelman and we want to add fancy features to 'more' (instead of creating a new tool named 'less'). We could do this freely, and all tools depending on peculiarities of "old more" could be pinned to use a "private" old version of the binary, while new ones would by default use the "new more". Then, the backwards tools could be gradually updated, until no one imported the "old more" and it could be safely removed from the nixpkgs repository. (While any external, non-nixpkgs package definitions could still backport the "old more" definition should they really need it.)
Does this reasoning have any holes?
And that-other-dude's-more would have a security vulnerability, and no-one would update it, and we'd all get pwned, oh the embarrassment.
Or, in other words, maybe the issue is cultural instead of technical, which would in practice, result in new users going to either more (the relic) or less (the bloated), depending on their views, instead of all new users going to less
edit: reading through the rest of the comments here, it seems a lot of people prefer more, for various reasons!
But that's just the thing - 'less' isn't "clearly superior" to 'more'. It is (or was, maybe this has changed) heavier weight and offers more functionality that may not be needed. Having both commands lets script writers use exactly the tool they need for the job. And it's not like the extra 35KB of keeping the 'more' binary around is really breaking the bank.
I wonder how many hours have been wasted altogether on people learning, and misunderstanding, which of more or less they should use?
At least for me personally, 'less' was what I always saw everywhere being used, and had used myself many times before I discovered that 'more' was a thing.
And when I discovered 'more', it took me maybe a minute to figure out that it's pretty much exactly like 'less', but that I didn't like it as much, and with everyone else seemingly agreeing on that, I didn't put any further thought to it.
cat -> from the obscure verb "catenate". A regular user would never, ever find the connection unless someone points it out. It should be "join" or "merge" or "unify" or something.
dd -> "data description". Really? It should be "blockcopy" or something.
grep -> "globally search a regular expression and print". Again, really? It should be "find" or "search".
ls, mv, cp, rm are kind of ok but in this day and age they should definitely be list, move, copy, remove by default (with aliases if need be). Heck, 99% of Unix commands are too short for their own sake.
cron -> "Chronos". Really?, third edition. It should be "scheduler" or something.
I mean, at this point we've all moved on and have memorized all these commands and parameters, but a lot of brain cells have died for no real benefit to humanity.
This is a word that perfectly describes exactly what cat does. Cat doesn't merge; that's ambiguous. Is a merge an interleaving? Sometimes yes. What does unify even mean in the sense of chaining data streams? Join? Close, but still unclear what it does. Does it operate on files? And what would happen to the already widely deployed join command that does something completely different?
Concatenate is a great word. Great words deserve to be used. I'm sorry that some of us haven't seen the crushing need to reduce our vocabulary to the double plus good amount of words in the newspeak lexicon.
What I'm not sorry about is that new users have to spend time to learn the system they're mucking around in before they can be useful with it. That's not a design flaw; that's a feature.
(Incidentally that link returns a blank page for me on FF mobile.)
The link to pg works on my FF Android. I'm using uBlock origin. Are you using some other adblocker or add on?
The page source is as simple as it could have been in 1996 :-)
The original link has a broken table layout with some unbalanced </table> and </tr>. Maybe that breaks rendering on your browsers, but why not on my Firefox?
It also finishes loading rather quickly, so it would only make sense that it's not even downloading anything.
And neither Firefox, nor Lightning Browser (WebView-based), nor CyanogenMod's Gello Browser (Chromium-based) show any form of error and just happily render a completely empty page.
Also, I do get the favicon displayed, so at least some form of connection to the server seems to be possible.
Edit: Just had another idea. It works for me when I tell Firefox to request the desktop site. So, maybe the server just gets confused by a mobile useragent-string...?
The page works for me when I tell my browser to request the desktop site.
curl -A 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19' http://www.unix.com/man-page/linux/1/pg/
returns nothing so it's definitely a mobile unfriendly site. $ docker run --rm debian:jessie less -V
docker: Error response from daemon: Container command 'less' not found or does not exist..
while more is present: $ docker run --rm debian:jessie more -V 1 ↵
more from util-linux 2.25.2It's using debootstrap --variant=minbase, which (from the man page) "...only includes essential packages and apt." It makes sense that docker would want only the bare minimum. And to be fair, but getting into nit-picking territory, minbase is the default for debootstrap, but debootstrap is not the default method of installing Debian: debian-installer is. So docker's Debian image doesn't install less, but they're not doing a default install, as in invoking debian-installer, and keeping the preselected choices as much as possible.
Huh? "less -R" has always been working like a charm for me, for scrolling in both directions. Maybe it's related to your terminal emulator? (I use Konsole.)
So it's still useful to me.
Powershell is an object-oriented scripting language along the lines of something like Python, just with different syntax and more of a focus on managing services. It also has reasonable syntax for applying one command to the result of another - the pipe operator. And it's reasonable to use it in day-to-day usage as a command line.
I've written a Powershell script to change an Exchange server setting we needed to change ever so often, faster than I could ever write a bash script to do the same. Under Linux, I'd likely have given up trying to use bash to edit a config, and just started writing an m4 file which generates the config as part of a cron job.
cmd is still around for the same reason sh is still around. For compatibility.
The last time I used one of those UNIXes (around 2006) everything seemed just like when I used UNIX for the first time in 1994.
Actually my first step after a successful installation when doing Solaris administration in 2000 was to visit http://www.sunfreeware.com
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\USERS\USER>ver
Microsoft Windows [Version 6.1.7601]
C:\USERS\USER>There is no "edit" or "edlin" any more or "ftp" or "telnet" or "tr" :(
For all other use cases, 'less' seemed clearly superior.
Sometimes, because more does less, more > less.
For instance ag (silver surfer) needs you to specify `ag --color` otherwise it will detect you are piping it and disable colors.
And if I remember correctly, grep needs a `grep --color=always` to achieve the same.
It's rather weird that the Open Source equivalent of PowerShell is now...PowerShell. Even if you don't like Microsoft or .NET, if you care about shells I'd recommend trying out PowerShell Core for an hour or two. It's only when you use it for a bit that you start to realize that you can guess commands based on the rules and actually be right and how big an improvement that actually is, rather than the current UNIX method of having to memorize more and more obscure trivia in order to get the computer to do what you want. I'm not sure if PowerShell itself is a long-term answer because of the .NET and Microsoft dependencies, but it gets lot of things right.
It's time we dropped the "Bash is good enough" arguments. There are now new Linux users starting every day, and asking them to learn that less is better than more is not funny.
I think when it comes to the combination of intuitive command names and terseness when required, VMS' DCL is still unsurpassed. Having commands with sensible names that can the be shortened and a really useable HELP system was a major plus and I've not seen anything match that since.
I know that if I do everything just right, then my scripts will handle filenames with spaces/newlines/other crazy characters, but I always mess up somehow. Nowadays if I ever want a script I'll distribute to people who might have spaces in directories, I write it in python even if it would be a 4 line bash script, just to avoid the issue.
You should be quoting variables when they're used though, there is a shell style guide put out by google that deals with this stuff.
https://google.github.io/styleguide/shell.xml?showone=Quotin...
When you learn the *NIX command-line from scratch, everything is special cases, so the whole experience is peering at man pages and slowly rote-learning commands and options. The only commonality is that if you try to guess, you'll probably be wrong. My patience with the philosophy of independent tools hit breaking point a while ago, when I had to start learning the different CLI tools from rival cloud providers - so much to learn, and no consistency at all.
I've tried to like powershell, but when I wanted "grep" I ended up having to do:
Select-String "str" -Path foo.txt | ForEach-Object { Write-Output $_.Line } | Out-File t.txt
.. because it has broken defaults such as truncating output to terminal width even when written to a file.
Then there's the weirdness around enabling script execution (rather more complicated than +x) and the remote execution system is much stranger than ssh.
FWIW, the script execution thing was dropped for the latest versions of Windows, and PowerShell Core (thankfully). I agree that the remoting is not much fun - SSH for Windows is currently due in October, so I presume that PowerShell will get SSH support around then.
But I think this is the point. PowerShell (or the spirit of it) would be more useful for new users because they don't need to spend time memorizing every single command and can start being productive earlier. It probably makes less of a difference if the commands are already part of your muscle memory.
Though to be fair, CMD is a lot more quirky and inconsistent than modern bash. So before the advent of PowerShell, I think you could have made the same argument on favor of ...nix and against windows.
For example, 'diff (cat a.txt) (cat b.txt)' does something very different from what you'd expect, but works OK for most inputs. The perfect combination for putting bugs into production.
I still like that powershell exists. Especially on Windows where they needed it most. On Linux, though, I'd rather stick with the devil I know.
I don't understand your point, PowerShell is a shell too, just like Bash or Zsh. When you call less, more or any other tool from Powershell, you still retain all the problems that are mentioned in the article. I think the article was focusing more on the ecosystem than anything.
Like Python, Node.js etc., PowerShell has one development team that will now be delivering one implementation across all of the operating systems. There's a packaging system included, so that third-party modules can also be uniformly deployed. The first-party and third-party stuff all has to follow the same rules and end up as modules in the same PowerShell installations, which avoids the long-running inconsistencies between tools, like man vs. info and different styles of option parsing.
At the moment, different versions of Windows do ship with different versions of PowerShell, which is annoying, but it's the same product and you can install new PowerShell versions on older systems to get a consistent environment across your machines.
To be fair, every programming or automation platform has that issue: Python and Ansible succeeded because people did like the basic systems enough to write code to extend their usefulness.
If I remember well, some time ago MS announced that on Windows you would be able to use Chocolatey as an additional source, which I thought was interesting.
PowerShell for Windows got this earlier in the year, and it's part of PowerShell Core. So with PS Core, you should be able to start a freshly installed copy of PS on whatever OS you are using, and add the AWS modules with this command:
Install-Module AWSPowerShell.NetCore
(Warning: this command does not work on the alpha release due to a bug - you need a workaround as described on the AWS blog: https://blogs.aws.amazon.com/net/post/TxTUNCCDVSG05F/Introdu...)
Nothing very impressive to anybody that has used any modern programming language, but now your shell has this too (if you use PS).
The actual package management system for PowerShell modules is PowerShellGet.
On Mac, PowerShell Core includes PackageManagement, and two "providers" - an adapter for PowerShellGet and one for NuGet, so you seem to be able to do either:
Find-Module AWSPowerShell.NetCore
(to use PowerShellGet directly)
Or:
Find-Package AWSPowerShell.NetCore
(to go through PackageManagement)
On Mac, PowerShell Core includes PackageManagement, and two "providers" - an adapter for PowerShellGet and one for NuGet, so you appear to be able to do either:
Find-Module AWSPowerShell.NetCore
(to use PowerShellGet directly)
Or:
Find-Package AWSPowerShell.NetCore
(to go through PackageManagement)
I didn't know most of this until I started poking around, so thanks for asking!
I think the article was more critical of commercial Unix vendors than Linux. From the article:
> Oddly, FreeBSD has done the most sensible thing; they've outright replaced more with less. There is a /usr/bin/more but it's the same binary as less and as you can see the more manpage is just the less manpage. OpenBSD has done the same thing but has a specific manpage for more instead of just giving you the less manpage.
> On Linux, more is part of the util-linux package but its manpage outright tells you to use less instead
The Free/OpenBSD choice seems sensible; presumably there are Linux distros which do the same. I imagine that if, say, Ubuntu or Debian makes a choice like this, it would propagate quite quickly to other distros; it would presumably be less of a breaking change than switching /bin/sh from bash to dash.
> It's time we dropped the "Bash is good enough" arguments.
I've rarely heard anyone claim "Bash is good enough". I do agree with the argument that bash is overused, and anything more than a trivial script should be done in a "proper" language (e.g. Python, which is installed by default on pretty much all Linux distros and OSX).
I'm not sure if there's a clear winner(s) for interactive use (i.e. a pareto improvement). Many use zsh, but I don't think it goes far enough. More radical alternatives like fish, ipython, etc. seem too fragmented at the moment. Maybe there needs to be momentum from a high-profile distro shipping such a shell as its default (while maintaining /bin/sh, /usr/bin/env bash, etc. for compatibility with existing scripts)
Incremental changes probably won't spread uniformly - when Ubuntu switched to dash, the Fedora developers explicitly decided that they would not ship dash and would continue with bash, because they have to maintain total compatibility.
In discussions of the new PowerShell release I've seen quite a few comments that boil down to "PowerShell is fine for Windows, but we don't need it on Linux", and I feel that, yeah, we do need a much better shell because what we have is nowhere near the best that can be done. Everybody that's used *NIX for a long period of time has to adapt to the classic shell way of doing things, but we shouldn't be pushing this mess on the next generation.
When do you even need to tell them this? Does it fundamentally change how they use the tool somehow? No, they'll see that you pipe stuff through less and that's it. Heck, I've been using Linux for 15+ years, and about 10 of those full time. The first I ever heard that "less is more" was probably ~3 years ago. It just doesn't matter.
What you're complaining about is esoteria (that is still littered all over the Windows ecosystem, e.g. the fingerprints of 8.3 file names still persist, long after it ceased to be a thing)
One thing that this thread has really brought into focus for me is that we treat the *NIX shells differently, because we are used to them, but IMO we ought to hold the shell to the same standards that we'd apply to any programming environment. If a new programming language with a REPL shipped today that was the quality of the shell experience that we've currently got, we'd think that it was ridiculous.
On minimal distros (say, Debian in the minbase configuration), more is more likely to be included than less. I haven't used any other small distros for a while but is util-linux normally there instead of other packages (actually, I wonder why minbase doesn't just use busybox).
(E.G. so that when someone digs out a floppy disk from who knows how long ago with a recently deceased relative's old scripts on it they'll still work.)
Also, that more's features are more likely to end up in something seriously constrained (busybox) means that if you're ever stuck on a really low end system you can still use more to get some critical things done (like page through a file or result set too large to read correctly otherwise).
:help manpager
Suggests export MANPAGER="env MAN_PN=1 vim -M +MANPAGER -"
Which doesn't work for me, but this does: export MANPAGER="/bin/sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu noma' -\""I am not a fan of Solaris's long standing refusal to touch anything.
This is what people often deeply misunderstand about traditional UNIX operating systems: one of Solaris' greatest features, in stark contrast to GNU/Linux, is the insistence on not breaking backward compatibility. Solaris has however delivered less(1) as standard since Solaris 8, so there is nothing stopping one from configuring their PAGER to it. In fact, I do the exact same thing in my OS builds of Solaris and SmartOS. It's called system engineering.
illumos has the entire GNU userland in /usr/gnu and it's packed with new features under the hood, but those will almost never be introduced such that they break someone else's stuff; it's the very advantage differentiator illumos provides over anyone else! And it's good engineering, adding new funtionality while not breaking existing one.
Features are use-case specific. One person's feature is another person's bloat. (Personally, I side with the article author on this.)
Or, are you responsible for delivering any services, and if so, do you not mind when someone else's changes cause you an outage?
Perhaps you have some private automation in place; do you not mind if your automation breaks because of someone else?
Apropos bloat, illumos is the only operating system codebase which gets faster and more efficient with every commit. If there are others out there, I have yet to see such a thing.
I'm happy enough if people say "okay, we didn't get this quite right, but we learned and we've made it better". And if the new approach isn't compatible, well okay. The short-term pain is usually worth moving forward in the long-term.
And when this happens, it's usually not a technical issue anymore, but a communication issue, which is a way harder problem to solve. If your solution to the communication problem is technical, i.e. let's always maintain backwards compatibility, then there's still the issue of communicating what the new, preferred method is. So I feel that if you have great communication with the people who care, it shouldn't impact them badly in the first place.
The danger of backwards compatibility is maintenance cost, and stifling new ideas to solve an existing problem better - people won't bother, because the effort of making something new would be overshadowed by the effort to retro-fit old behaviour.
Still though, I get the point of changing stuff just for the sake of change is bad. I'll ignore the hyperbole about illumos though.
And the fact is, when there's a piece of core that nobody uses, and has since been replaced by superior tooling, The Right Thing to do is to rip it out, and link to said superior tooling if it has a compat mode. I mean, it's not like Solaris still has ptrace or /dev/poll.
...The only way that could ever work without breaking existing software running in the wild would be for that superior tooling to be backwards compatible. SunOS (illumos) does this all of the time. For example, GNU options like -C have been added to SVR4 tar(1) on illumos, thereby enhancing, but not breaking existing functionality.
Otherwise, how would you determine whether someone isn't using something, and that on every Solaris / illumos system on the planet?
Have they optimized grep the way GNU did?
I don't know about grep(1) in particular, we have fgrep(1) on illumos for that, which comes all the way from AT&T's SVR4. We also have egrep(1) in addition to grep(1). HP-UX for example, being a SVR4 system, has fgrep(1) and egrep(1) in addition to grep(1) as well. I use fgrep(1) every day; only when I need to use regular expressions do I use grep(1).
I know cat(1)'s been optimised. If you're curious enough, you can check out Solaris's grep(1) code here:
https://github.com/illumos/illumos-gate/tree/master/usr/src/...
Lupus in fabula: you can also see that the -H option has been added to grep(1), which illustrates my point that illumos does this all of the time[1].
I mean, it's not like Solaris still has ptrace or /dev/poll.
?
% ls -l /dev/poll
lrwxrwxrwx 1 root root 29 Jul 24 2013 /dev/poll -> ../devices/pseudo/poll@0:poll
% man ptrace
Standard C Library Functions ptrace(3C)
NAME
ptrace - allows a parent process to control the execution of
a child process
SYNOPSIS
#include <unistd.h>
#include <sys/types.h>
int ptrace(int request, pid_t pid, int addr, int data);
...
...
...
% uname -srpmi
SunOS 5.10 i86pc i386 i86pc
...so I'm baffled by your statement. Did you mean to write the opposite? What were you actually trying to say?[1] https://github.com/illumos/illumos-gate/commit/41599e9fdccb4...
My main point was that if you have a superior utility that doesn't break compatability, like less, than why ship the original? Less is better than more, and it doesn't break compatability in any way I know. That's why setting it as $PAGER works.
The fact is, a lot of superior tooling is backwards compatible. PCRE (although superior is up for debate) is fairly compatible with extended regex, GNU tar is compatible with posix tar, both syntactically, and semantically with the aid of -H. Heck, it's compatible with the v7 archive format.
But there may be (much) larger softwares superseded by more modern versions, both present on the os.
- If more and less are split in two: more does not page well (no scrollback), and less does two jobs: paging and blocking the scrolling.
- If more gets dropped in favor of less: less is a rather good pager, and serve only its own purpose of paging lines of text in different way.