A common "idiom" for viewing large amounts of command output is to pipe it to less, via command | less. However, it's also possible (perhaps only in bash, haven't tested in other shells) to use the less <(command) syntax, but less tends to complain /dev/fd/63 is not a regular file. After poking around in /proc/*/fd, I see that in both cases, it's reading from a pipe. The only difference is that in the first case, it's stdin being redirected. In the second case, it's getting /dev/fd/63 as a file name. Does less somehow "ignore" the regular file check when reading from stdin? Also, how does it determine that /dev/fd/63 isn't a regular file, even if the contents are text?
2 Answers
less normally refuses to open non regular files like pipes or also binaries. You can use the -f operator to force less to open non regular files:
less -f <(command)
Another approach is to use process substitution:
less < <(command)
This causes the pipe that was created with <() to act as standard input (STDIN) for less.
-
1I believe that you’re a bit confused on the nomenclature.
<(command)is process substitution. Changing that to< <(command)is just making it complicated.Scott - Слава Україні– Scott - Слава Україні2014-07-25 02:21:08 +00:00Commented Jul 25, 2014 at 2:21
lesstends to complain/dev/fd/63is not a regular file
The solution to that, under GNU less at least, is the use of the -f option:
less -f <(command)
Under normal circumstances, less will not open non-regular files (stdin excepted, obviously). This is for your protection. -f forces non-regular files to be opened.
file <(command)says:/dev/fd/63: broken symbolic link to pipe:[10973768]'/dev/fd/63and then pipes this into the command. The problem is, is that this file is notseekablemeaning it can only be read as a full file without random access. One of the main features of less is that it doesn't read the whole file at once, and so causes this error message.Using a text editor that reads the whole file at once will work. EtcVistdin? Isn't that not seekable as well?Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the "file" resulting from process substitution is not a regular file.