Please Help Me...

Hi,

I am beginner using unix. I want you to help anybudy to show me the script to count data in directory....below this my directory....

/ebs/home/ebs_dba/nazrul/temp
MKZSX510>ll
total 0
-rw-r--r--   1 ebs_dba    users            0 Apr 19 16:50 blabla.edi
-rw-r--r--   1 ebs_dba    users            0 Apr 19 16:50 filename.std
-rw-r--r--   1 ebs_dba    users            0 Apr 19 16:50 first.txt
-rw-r--r--   1 ebs_dba    users            0 Apr 19 16:50 second.txt
-rw-r--r--   1 ebs_dba    users            0 Apr 19 16:50 whatever.bat

What data you want to count?

i want to script to show total all this file below.

 
rw-r--r-- 1 ebs_dba users 0 Apr 19 16:50 blabla.edi 
-rw-r--r-- 1 ebs_dba users 0 Apr 19 16:50 filename.std
 -rw-r--r-- 1 ebs_dba users 0 Apr 19 16:50 first.txt 
-rw-r--r-- 1 ebs_dba users 0 Apr 19 16:50 second.txt 
-rw-r--r-- 1 ebs_dba users 0 Apr 19 16:50 whatever.bat

why you want to use script?

I think you can easily do this by this command

ls -l dirname

The total of what? What data do you want to count? The total size of the files? The total number of the files? Some sum derived from an obscure algorithm involving these files, a chicken, and a bucket of goat blood?

I want use script because i have a task to count data for each directory that given.So I want try first how it execute...You understand what i mean..Hope you can help me..

From your output I think that it is not having the total line.
So do you want like this?

ls -l | sed '1d'

Hi all,

I want to script count the total number of file in directory.Hope you can help...:slight_smile:

Use the following command.

ls -l | grep "^-" | wc -l

It will give the number of files in the current directory.

If you want to know the number of files in a specific directory , then you need to specify its name as

ls -l  <directory_path> | grep "^-" | wc -l

can you write for me the script?

it's starting to look like homework. you have all answers you need. all you need to do now is to use them!

good luck