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:
A script that takes any number of directories as command line arguments and then lists the contents of each of these directories. The script should output each directory name prior to listing the files within that directory
2. Relevant commands, code, scripts, algorithms:
3. The attempts at a solution (include all code and scripts):
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
BITS pilani, Hyderabad, India, B.V. Prasad Babu, System Programming
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).
Last edited by Scrutinizer; 11-28-2012 at 10:40 AM..
Reason: code tags
1) Variables can't have spaces in their names. No of dir = $# is wrong.
2) You shouldn't put spaces on either side of the equal sign. something = asdf is wrong. Do something=asdf
3) You got your if-statement nearly right, but not quite. Don't capitalize anything. Your ; is also in the wrong place.
If it helps, imagine it like this:
To combine any of that onto one line, you'd put ; where there's newlines, so you'd get if [ something ] ; then
4) You can't put a variable in a variable like this: ${$count} it just doesn't expand there. There's a better way, anyway.
The shift command will get rid of the first parameter. If your parameters were a b c d before, after you run shift they will be b c d. So you can loop until $# is zero, running shift at the bottom of your loop, using $1 every time instead of using $1, $2, $3...
I would also add and comment:
What is the if supposed to do here?
I see you are comparing a string (count) with a numeral since you are using -le How can you expect that to work?
Hi,
I have a main folder 'home'. Lets say there is a folder 'bin' under 'home'. I want to check the list of files under subdirectories present under the /bin directory created in the last 24 hours.
I am using the following find command under home/bin directory:
find . -mtime -1 -print
... (3 Replies)
Hi,
My apologies if my query is already available on this forum but I am new and could not find.
I need a script to list all directories/sub directories and files with permissions/groups/owners. The script would run from home directory and should capture every directory. How do I do this?
... (4 Replies)
Hi Unix Gurus,
I need to list all files in a Unix Directory which either end with a
.pdf or .rtf and they should be case insensitive ie .Pdf , .pDF , .RtF etc are also possible.
How can i accomplish this with with a ls command ? If not then a find command. (6 Replies)
hello every one,
i'm a novice in the field of Linux, so please help me out with this problem.
a text file with the following syntax is given:
file1
file2
file3
file4
file5
a script is to be written to list all d file names and tar the files with the filename... (3 Replies)
How can I list the files in a directory and just show the file size, date stamp, timestamp and file name..
I've been trying to ls -lrt the directory to a file and then use the cut command but I'm not having any luck with getting the proper results.. I thought i could use the -f switch and count... (4 Replies)
Hi,
Edit: The title should really read listing files in a non-parent directory, sorry!
Im trying to get one of my Bash scripting assignments done for uni and now I'm stuck. This is probably going to be one of those kick yourself moments but, in my script I have a variable usrDir which... (2 Replies)
Hi ,
I want to list all files in the order of size . Just want to know which files occupies more size and which occupies less size .
Is it possible with ls command ? :)
Thanks,
Arun. (1 Reply)
Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories.
The following command also shows the files but I only want to see the directories.
ls -lrtR * (4 Replies)