Leon Anavi
IT Tips && Tricks

Administration

Created: 27.09.2009 22:50 Last Modified: 27.09.2009 22:56 Views: 3654
Keywords: console, LInux, ls, man, wc

Linux: Number of Files in a Directory

The Problem

How to count the number of files inside a Linux directory? How to determine the number of files with same extension?

The Solution

Use the ls command to list one file per line recursively and combine it with the command wc.
ls -1R | wc -l
To determine the number of files of a certain format specify its extension as an argument to ls.
ls -1R *.mp3 | wc -l

Man pages

ls
wc


  Home | About | Contact | Disclaimer | Sitemap 2009-2016 Leon Anavi. All rights reserved.