1747997 Members
4632 Online
108756 Solutions
New Discussion юеВ

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 6
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.
Vadim Loginov
Advisor

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