0

I want to keep only the last line of tree's output or the file+directory count report. Preferably, with the -a switch.

An example output I desire:

585 directories, 37722 files

Is this possible with tree?

Sepp A
  • 53
  • 4
  • 2
    Does this answer your question? [How to display only the last line of a listing ?](https://unix.stackexchange.com/questions/192760/how-to-display-only-the-last-line-of-a-listing) – phuclv Feb 06 '23 at 01:20
  • @phuclv it does, but I'm looking to see if there's any combination of flags for `tree` that would skip listing. That would take some time if a directory is big. – Sepp A Feb 06 '23 at 13:17
  • that'll need a different command and the question should be `command to output file and directory count` instead of *tree command to only output file and directory count?*. It's very simple to count in awk or perl – phuclv Feb 06 '23 at 14:31

1 Answers1

1

tail is a standard filter to print last line(s). To print one last line use tail -n 1.

tree -a | tail -n 1
Kamil Maciorowski
  • 19,242
  • 1
  • 50
  • 94