Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
cancel
Showing results for 
Search instead for 
Did you mean: 

command needed 3

SOLVED
Go to solution
ng_7
Regular Advisor

command needed 3

hi, can please provide command for the below :

1. to list only directory (in a directory ,
there may have file and subdirectory, i
want to list only subdirectory)
2. to find out total size (KB/MB) for a
specific file, eg : to find out total size
for *.t files

thanks
6 REPLIES
A. Clay Stephenson
Acclaimed Contributor

Re: command needed 3

1) try ls -d and then man ls.

2) ls *.t | awk '{sum += ($5 + 0)}END {print sum}'
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: command needed 3

1) try ls -d and then man ls.

2) ls -l *.t | awk '{sum += ($5 + 0)}END {print sum}'
If it ain't broke, I can fix that.
Dennis Handly
Acclaimed Contributor
Solution

Re: command needed 3

>1. to list only directory (in a directory, there may have file and subdirectory, I want to list only subdirectory)

Not sure what you are saying, just list what you want. If you only want the name of the directory, add "-d".

$ ll subdirectory

>2. to find out total size (KB/MB) for a specific file, eg: to find out total size for *.t files

Use awk:
$ ll *.t | awk '{ total+=$5 } END { print "Total MB:", total/1000000 }'

Of course you may want (1024*1024) for MB.

Re: command needed 3

Hi ng,

Hi ng,

Try ls -l | egrep '^d', to get a list of subdirectories in a folder.

Regards,

Vad
Dennis Handly
Acclaimed Contributor

Re: command needed 3

>Vad: Try ls -l | egrep '^d'

No real reason to use egrep when grep will do.
ng_7
Regular Advisor

Re: command needed 3

Sorry for my delay in assigning Point.

Thanks to everybody..You guy are so helpful