ugakid
September 29, 2004, 5:57am
1
Hey guys....
couple questions...
I am working a problem set and can't answer this:
1) Suppose you are in a directory that contains a file called "foo." You want to create a new file called "bar" that contains the sorted contents of "foo" in the parent directory of the one you're in. How would you do it with one command?
2) Most (but by no means all) of the programs on klotho are in "/usr/bin". The "ls" command, by itself, can't tell you how many programs are in that directory, but there's a clever way to get that information by combining "ls" with another command. Can you figure it out?
3) How, using UNIX, would you determine what day November 9th, 1066 fell on?
Thanks in advance.. this is due in a few hours... so urgent
From the rules
(6) Do not post classroom or homework problems.
ugakid
September 29, 2004, 6:12am
3
These are exercises which are integral to my learning unix... i'm stuck and would like to figure these out... Thanks
In that case, post what you have got so far.
What work have you done to solve the problems yourself?
Have you searched these forums to see if people have already answered these questions?
Have you searched http://www.google.com ?
Have you searched the man pages (using the apropos command to search the short descriptions)?
People will not be willing to serve you up "answers on a plate"
Cheers
ZB
ugakid
September 29, 2004, 6:31am
5
yes... have been working diligently and these are 3 of 20 i was unable to solve (just figured out the calendar question)...
as far as question 1 goes....
i've tried the following but have gotten confused as to how to create a file to the parent directory in one move..
this is what i attempted to no avail...
sort foo > .. bar was a feeble attempt but have exhausted myself searching for similar issues on google..
best regards
ugakid
September 29, 2004, 6:33am
6
on number 2 i don't mind telling you i am completely lost here..
while seaching with the man function i think i need to somehow use wc along with ls but not sure exactly how to do so..
any help would be most appreciated..
Well, I'm not sure that the moderators would agree, but it looks like you have been trying hard to solve the problems.
You are also very close on both counts.
For your first question - try "sort foo > ../bar" - as I say - you were very close
For your second question, you are correct that you need wc. Something like
"ls -1 /usr/bin | wc -l". (That's ls minus ONE and wc minus ELL)
I'd suggest that you start studying pipes and redirection, as these are fundamental concepts when working with the UNIX command line.
If the mods want to lock/delete this thread, fair enough, but I think the OP had done most of the work anyway.
Cheers
ZB
ugakid
September 29, 2004, 6:40am
8
Much obliged for your assistance..
we all know how frustrating learning a new OS can be.. not to mention I've been at it forever..
Have a superb day..
Most of us bend the homework rule every now and then. I suspect that one question I answered yesterday was a homework thing.
But I'll lock this thread anyway...