Quick programming question

I’m using Mandriva Linux. I’m programming in C. Now, my question is regarding being inside a terminal. I know that the command to make a directory is mkdir then the name you want.
I can’t figure out another way to do it though. This is the problem in my homework:

 If your working directory is /usr/alex/ecs30, provide two ways to create the subdirectory called hw1.

So far I have one way.
Type mkdir hw1

What is the other way?! I just can’t figure it out!

You know, I’ve never met a Unix/C basics teacher I liked. Most of them have no idea what they’re doing and the rest are so inexact in their language you’d have to be psychic to understand what they want. Too many people ruined by such crap…

There is no other way. The mkdir command is a direct link to the system kernel command of the same name. If you want to make a directory you must at some point use this command.

Now, there are commands that have as a side effect the creation of directories, such as unzipping or untaring an archive that has directory information…
You can make some directory foobar and rename it as hw1.
You can use the window manager to create a directory.
You can use some program like nedit or emacs and save a file as ~/ecs30/hw1/foo.txt.

If those don’t satisfy your professor tell him to stuff it up his nose.

Hope this helps.

I just decided to say “copy an old directory and rename it.” I probably should have said “use the window manager”, but I don’t feel like printing out another copy of my homework.
My teacher is actually really cool. He is the easiest teacher to listen to out of all of my classes. There are only about 60 people in the class, so he has no problem with answering questions.
It might have something to do with him programming since 1980. …Or that he used to be a hippie with a bushy beard and shoulder-length hair.

mkdir dirname and sudo mkdir dirname? :smiley:

lol 1234567890

perharps

mkdir /usr/alex/ecs30/hw1

cd /usr/alex/ecs30
mkdir hw1

:slight_smile:

@Willington: good point, that’s the most probable answer, actually… :slight_smile:

Yes. I changed it to that right before turning it in. It doesn’t need the cd though because it is already in that directory. Thanks for the help!

Problem solved… well, I’ll see about that later.

Hmm, yes, Wellington is probably right. Sorry I seemed so uptight. The actual question I still think is moronic. I’ve been programming only a couple years less than that guy and I had no idea what he meant.

I’m glad your professor seems to be a good one. My experience is that after someone finishes his class I have to help a lot of his students figure out how to make things work. I can’t tell you how often I’ve had something like the following (actual experiences!):

student - My program isn’t compiling. Can you help me?
me - Sure, let’s see it.
student brings a 4 by 3 inch emacs window on a 20 inch monitor to the front and points at the ten half-lines of code visible.
me - No, I mean your compiler output. What does it say is wrong?
student brings a similar-sized xterm to the front and points at a mass of compiler output all crammed inside.
me - a suggestion: make your window larger so you can see what you are doing.
student resizes window about an inch larger right and bottom.
me hits maximize button. I explain that the more you can see the easier it is to understand. you can always minimize the window whenever you don’t want to look at it.

at the top of the display it indicates some local include file is not found.
me - it looks like it can’t find the file “foobar.h”. is it in your directory?
student types “ls” and about 500 files scroll by. student is in his home directory. everything he has ever done is there. student is not sure which file he is currently editing.

at this point, I feel like finding his professor in some dark alley and beating him up…

/me puts rant away
:o

Anyway, if, as you learn to program, you can remember how to look at things from the outside in (that is, not knowing what you know) then you’ll do OK.

Er…

Ya. That was an interesting story. The very first thing we learned to do is navigate through Linux using the terminal and move files and create directories. I think your student could have used that tutorial that I did.
My teacher is also teaching good programming techniques and styles. Example: where to put spaces, indents, caps, comments
He says that you generally have a text editor and the terminal open at the same time. Unfortunately, I am using ssh to do all of my work on a lab computer. I’m not sure how to make the text editor open/save files on another computer.

(Also, I don’t think that Mandriva has gcc, which is what compiler we use. Is that an extra thing I have to download? Maybe I’ll get to it someday… ooh, more homework due next Wednesday… )

edit: I just learned how to use functions with input arguments. That will help very much with top-down design.

edit number 2: I was just thinking about the text editor and thought up the obvious answer. I have been using vim in the same terminal to edit the source code. Then just now I thought “Duh! All I have to do is open up another terminal at the same time.” I think that is the best way to do it for now.
(It is better that I use ssh and save stuff onto the school’s server. That way I don’t have to mess around with sftp.)

@Duoas
You would have thought it was common sense to organize his files in to appropriate an manageable directories.
Can’t really blame the lecturer for the students lack of sense, can you?

kit89
Yeah, for some of them it should have been common sense… they knew enough that by the time I got to them they should have known about the mkdir command :rolleyes:

But, sadly, for most the teacher should have said something. People just learning don’t know any better until someone says something or it is too late (and it bites them).

samf
You can always use Ctrl-Z to switch the current foreground process to background. Use jobs to list all background processes. Use fg job-id to switch a specific process into the foreground.

The answer I submitted was correct.