I sometimes use less to quickly page through a small collection of files using something like

less brscan/*/*

and then I use :n to cycle through the files

If I have a folder/s e.g.

│   ├── conffiles
│   ├── control
│   ├── postinst
│   ├── postrm
│   └── prerm
├── etc
│   └── opt
├── opt
│   └── brother
└── usr
    ├── bin
    └── lib64

in this example less will pick up the files in folder DEBIAN

       ├── conffiles
       ├── control
       ├── postinst
       ├── postrm
       └── prerm

but it wont descend into other subdirectories, it just errors:

brscan/etc is a directory
brscan/opt is a directory
brscan/usr is a directory

is it possible to get less to page the files in these subdirectories?

Im thinking something like

find brscan/ | xargs less

but its not working - still picking up directories

  • 1
    Something like this find brscan/ -type f -print0 | xargs -0 less ?
    – FloHimself
    Apr 14, 2015 at 8:59
  • works! I left out the -print0 and the -0 option in xargs i.e. find brscan/ -type f | xargs less thanks! Apr 14, 2015 at 9:05
  • 1
    Great! There is a note about -print0 and -0 in the man page of xargs and explained why you should use it.
    – FloHimself
    Apr 14, 2015 at 9:14

2 Answers 2


specify -not -type d to omit directories from the find result

find -not -type d | xargs less

or better:

find -not -type d -print0 | xargs -0 less

which handles filenames with spaces in them better.


With bash, globstar option enable, you can:

shopt -s globstar
less brscan/**/*

But it also includes directories. With zsh, you can filter expansion to regular files only:

less brscan/**/*(.)

All of the above will fail if too many files return. The safe way is using find:

find brscan -type f -exec less {} +

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.