Modalitati de numarare a fisierelor dintr-un director in Linux.

Pentru a vedea totalul de fisiere dintr-un anumit director, o poti face direct din linie de comanda sau cu un script.

Linie de comanda:
Trebuie sa fiti in directorul respectiv si sa executati comanda:

ls -l |wc -l

sau


ls -l cale_director |wc -l

Script:


#!/bin/sh
NUMBER=0
count ()
{
for temp in $1/* ; do
if [ -d "$temp" ] ; then
count "$temp"
elif [ -f "$temp" ] ; then
NUMBER=$(($NUMBER+1))
fi
done
}
count $1
echo "$NUMBER files were found"

Scriptul primeste ca parametru calea catre directorul pentru care vrem sa aflam numarul fisierelor.

Vezi si alte tutoriale

[ad name=”v1″]

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

©2019 KLEO Template a premium and multipurpose theme from Seventh Queen

Log in with your credentials

Forgot your details?