Overview for ls

How to sort files in folder from the biggest to smallest

Command ls in Linus is very powerful and you can list files any way you want using proper parameters. In case we want to sort files in a folder by size descending, we run a following command:

$ ls -S

This command show all files in a folder and list them descending by file size, but there's a problem, which we will explain in an article below. It's good to write about commands and outputs, but the best way, from my point of view, is to show everything on a real example (I tried it on openSUSE Linux, but ls is a command, which works in every Linux distro, so don't be afraid something will work different way on your system.

Read more

Written by Administrator on Saturday May 2, 2020

How to count files in folder (Modicia Linux)

When you are working with huge amount of files, sometimes you need to count them. In Linux you don't have to install any additional software to do it. Linux terminal and bash is a very powerful tool for files routine.

Count files and directories

To get the number of non-hidden files and folders in defined folder you should run this command:

$ ls | wc -l

Example:

count files and directories in Linux - example


Read more

Written by Administrator on Thursday April 23, 2020

How to count number of folders in folder|directory in Linux?

To count number of folders/directories/files in folder/directory is possible using wc command with a parameter -l. But we have to be sure, that we are counting only folders, so let's filter only folder using ls command, and then count then.

My example:

$ pwd
/home/dima/

Then let's take a look, which files and folders we have:

Read more

Written by Administrator on Saturday April 11, 2020