Linux Operating System (MOSC)

MOSC Banner

How to count number of files in a directory and store that result in a variable?

edited Jun 5, 2013 11:21PM in Linux Operating System (MOSC) 2 commentsAnswered ✓
Hi,

How to count number of files in a directory and store that result in a variable?

count=ls -1 | wc -l

count=find ./ -name *.dat -type f | wc -l

I am using the above two queries both are returning the results but not storing that result in count variable. Value in count is always NULL. Please advise.

Thanks,

Usman.

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center