Need some help with my homework

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:
    Hi, since I'm relatively new to Unix I need some help. I've installed FreeBSD 8 on a virtual machine and I've done most of the tasks but don't know if I'm right or wrong ;/
    Here it goes:

  2. Why do folders /bin and /usr/bin usually come out at the first place as an output of the command echo $PATH?

  3. Explain what would be the result of the command $ `date`

  4. You want to concatenate the two files foo1 and foo2 but you have to put some text from the command line between them too. How would you do that?

  5. If a command procedure contains a command:
    echo ${d-'*'}
    what would come out?

  6. Can you use sh < foo.sh instead of sh foo.sh to execute a script?

  7. Relevant commands, code, scripts, algorithms:
    echo $PATH
    $ `date`
    echo ${d-'*'}

  8. The attempts at a solution (include all code and scripts):
    Ok, first of all I don't know why but I can't create files to test some commands ;/ I mean I write for example cat >file1 and it says "Cannot create file1. Read-only file system."
    Here are my answers dunno if I'm right or wrong so please help me :]

  9. Because in those folders are the most important system scripts, files etc. that are being used when the operating system loads

  10. In my case it came out: Thu: not found.
    But when I change `` to ' ' it says the correct date. Is that the catch here?

  11. Aah maybe:
    cat >>foo1 foo2 >foo3 or maybe not?^^

  12. It prints out - * ?

  13. I'm not sure about that one - maybe you can, because < is used for input

Thanx a lot

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    New Bulgarian University, Sofia, Bulgaria, N.Gadjev, CSCB584 UNIX

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).

  1. Because the PATH variable defines the directories your shell looks in for commands you type that aren't built into the shell. For instance if you type ls, and ls isn't an internal shell command, it looks through the directories in PATH for an executable file with the same name as the command you typed and tries to execure it. /bin and /usr/bin are used to store commonly used executable files such as ls, grep, chmod, etc.

  2. Because the `` quotes are command substitution quotes. the shell will execute the command between them and then substitute is ouput in place of `command` as if you had typed it. `date` tries to run a command named whatever date outputs on your system.

  3. Its easiest to use three seperate commands. If it takes longer to figure out how to do something in one command than it takes to type 3 and computing resources aren't an issue because you are only going to do it once or you have a tiny amount of data, why waste your time trying to figure out how to make a complex command work?

cat foo1 > newfile
somecommand >> newfile
cat foo2 >> newfile
  1. ${d-*} means if d is unset then assign * to d. see the parameter expansion section of the ksh, sh, or bash man page for more info.

  2. yes

1 Like

Thanks a lot mate for your time and help :slight_smile:

why are you doing his homework in full ?

1 Like

They made an honest attempt to the point of installing FreeBSD to test their answers. It takes a long time to learn UNIX and for a beginner it is often more helpful to explain things than send them to man pages that they probably already looked like and don't understand. I have been in the position of training new UNIX administrators and even those with IT related degrees with no UNIX experience can have a hard time understanding man pages.

2 Likes