ls number of directories in root help?

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions ls number of directories in root help?
# 1  
Old 03-17-2011
ls number of directories in root help?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

I have been reading for several hours. Im not getting anywhere... well Im not getting there fast enough. so I thought I would ask the expertsSmilie

I need to list and count directorys in root. this is part of a class im taking. I dont know scripting much at all. well not at all. still I need the out put to look like this

the root directory on "hostname" has "some number" directorys
#then list the directroys like this, or close to it.

2048 r-x 2 14:26 bin
512 r-x 2 15:59 bsd-src
3072 r-x 3 14:45 dev

and so on.

with ls -gko / I get some of what I need. but I need some hints/help with the rest.

ls -gko /

drxwr-xr-x 3 4 feb 2 2010 bin
drxwr-xr-x 3 4 feb 2 2010 boot

and for some reason, adding the -d option that I think should be giving me only directorys is giving me this one line.

drxwr-xr-x 33 4 Jan 3 13:46 /

help wanted

thanks



2. Relevant commands, code, scripts, algorithms:

I have been trying to use ls - options just to get the fields right but I understnad I will need to use
ls
echo
cd
and regular expressions.

3. The attempts at a solution (include all code and scripts):

Im posting this from windows and I cant get all the attemps from my linux machine to here. I can if I really have to but I think you can see I have been working on this problem for about 2 days now. Im just not good at c yet and this seem like a rather advanced problem for a intro to unix course.


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

school = pima.edu
intro to unix =CSI137
instructor is B. Tucker


Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 03-17-2011
Something like:
Code:
ls -gko / | egrep '^d'

?
And number of directories:
Code:
ls -gko / | egrep '^d' | wc -l

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 03-17-2011
what is wc?

thanks for the help

---------- Post updated at 12:23 PM ---------- Previous update was at 12:18 PM ----------

ok.. I think I know what wc is supposed to do. but the output is a unexpected result

infact wc -l in the root dir just gives me a blank next line that I have to cntl c out of .
# 4  
Old 03-17-2011
Did you run it the way I provided? With ls and egrep?
# 5  
Old 03-17-2011
sorry.. I tryed to run it by its self..


so.. how do I hook long regular expressions together? or is that possible.

I thought I was to use ! but it seems there is some other operator that lets you string commande together? or do I need to assign varibles? this is really hard. I know nothing about programming

---------- Post updated at 01:36 PM ---------- Previous update was at 01:23 PM ----------



so im trying

echo ' the root directory on' $HOSTNAME 'has' ls -gko / | egrep '^d' | wc -l

which dos not work. im sure the problem is between 'has' and the ls cammand. Im thinking that I may need to use the ls command and save the output to a varible? and then have the echo command display that varialbe? am I even on the right track?

---------- Post updated at 01:39 PM ---------- Previous update was at 01:36 PM ----------

oh oh.. i got it.

echo -n ' the root directory on' $HOSTNAME 'has ' ; ls -gko / | egrep '^d' | wc -l

wow.. thanks for the help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find number of directories

Hello! Yesterday I tried to make a shell script in order to find the number of directories in my home directory. I tried with this: c=0 for dic in $(find ~ -type d); do ((c++)) done echo $c The result is 4071. If I enter "find ~ -type d | wc -l" code, the result is... (3 Replies)
Discussion started by: kecsab
3 Replies

2. Shell Programming and Scripting

Script to count number of files in directories

Hi All! I would like to have a script that will count the number of files at the top of the hour of soome directories and mail the results to me. I was thinking on : a=`/directory/subdirectory/ | wc -l` echo "/directory/subdirectory :$a" b=`/another_dir/subdir/ | wc -l` echo... (12 Replies)
Discussion started by: fretagi
12 Replies

3. Solaris

New root account with Different UID number

Hi Unix Gurus . I have requirement where in which - I would like create duplicate root equivalent account with all the privileges equal to root. Is it possible to create this duplicate account with different UID. ? this id i would like give it to my teams - who does multiple activities using... (2 Replies)
Discussion started by: johnavery50
2 Replies

4. UNIX for Dummies Questions & Answers

Number of files in all (sub-)directories

Hi, I need a list of the number of files in all (sub-)directories e.g.: /a/b/c 1364 /a/b 125 /a 362 etc. Should be nice to have the list sorted from high to low. Regards, Wim (6 Replies)
Discussion started by: deleriumdog
6 Replies

5. AIX

find command to list all the 777 files and directories owned by root user

Hi I'm logged in to an AIX box now and we need to do an audit on this box. cbssapr01:# pwd / Which command will show all the files and directories owned by root user with permissions as 777 ? (8 Replies)
Discussion started by: newtoaixos
8 Replies

6. Shell Programming and Scripting

Need help with examine the number files in directories given as arguments

Hi , this is homework .. I have to finish it tomorrow, I did my best , but I found it so difficult .. Can You HELP Me ??! Write a bash shell script filestatic. The script should examine the number files in directories given as arguments (parameters) to this script. a. if one argument is... (1 Reply)
Discussion started by: abo-el-sos
1 Replies

7. UNIX for Dummies Questions & Answers

How to get number of files and directories?

Hi All, can you please tell me how to get no.of files and directories in the given directory.:confused: (4 Replies)
Discussion started by: raju110384
4 Replies

8. Shell Programming and Scripting

Help with command to Move files by X number to seperate directories

Hello, I need help finding a script that will allow me to move files from one directory to another directory 10k files at a time. I have a directory that has 100 K files in it. I need to have those 100k files broken apart to separate directories each with 10k files in them. Here is the... (8 Replies)
Discussion started by: Geo_Bean
8 Replies

9. Shell Programming and Scripting

Bash scripting to compare N number of files located in two directories

I want to compare "N" (around 2000+) number of huge files located in a directory A against "N" files located in a different directory using Bash scripting. Please help me with any scripts available. Thanks. (2 Replies)
Discussion started by: Sangtha
2 Replies

10. Solaris

how to find the software packages and root directories

Hi all, i have one requirement to audit the software packages list in unix server. For this the i go through #pkginfo command.But there are lot of packages. i get confused how to find the software packages and root directories paths. Please let me know whether i am going correct way... (1 Reply)
Discussion started by: krishna176
1 Replies
Login or Register to Ask a Question