Find the answer to your Linux question:
Results 1 to 2 of 2
I am taking an online Linux class, which is mandatory for me to graduate. Unfortunately I got the worst online teacher ever, he never respond to any e-mails. I have ...
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    1

    I am so lost !!!

    I am taking an online Linux class, which is mandatory for me to graduate. Unfortunately I got the worst online teacher ever, he never respond to any e-mails. I have no idea what going on in this class so I am turning to you guys.


    Here is the questions for the week, Ok I don't expect anybody to just give me the answers. I want to learn the stuff so if you guys can just direct me to where I can find these answers and learn more basics cause we are using " A Practical guide to Linux by Mark G. Sobell" and I can't seem to make anything of it .
    We are writing a midterm and a quiz this week and he didn't even tell us what material we have to cover. Waste of money if you ask me.

    1. Here is a fragment from a shell script:

    while who | grep robert >/dev/null

    Which command's exit status (who or grep) will be used to determine if the while's condition is TRUE or FALSE?

    ______Who__________


    2. What type of loop will execute all the commands between do and done as long as the loop's condition is FALSE?

    _____Until___________


    3. What type of loop would be used if we wanted to execute a group of commands once for each item in a list?

    ____For____________


    4. Complete the following code fragment so it runs the commands between do and done on all files in the current working directory that start with an upper-case letter and have .c as the last 2 characters.

    for _________________________________________
    do
    echo $x
    done


    5. Complete the if statement in this code fragment so it will print "Yes" if the variable named temp is set y and "No" if it is not. (hint: use the "test" commend)

    if __________________________________________________ ____
    then
    echo "Yes"
    else
    echo "No"
    fi

    6. Write a for loop to do the following: Assume we have a directory that has (amongst other things) the sections of a book we are writing stored in 10 files named section0, section1, ..., section9. We want to print to stdout each filename followed by the contents of the file for those (and only those) sections stored in section3 through section8 (inclusive). Write a for loop to do so.
















    7. Write a shell script fragment that contains a while loop that checks every 5 seconds (or so) to see if the user robert is logged in. As long as robert is logged in, the script should print to stdout (screen) Bob's still logged in! Once robert logs out it should print to stdout Bob just logged out! Make sure to send any unwanted output to the null device (bit-bucket) so it doesn't show up on the screen.









    8. Assume we have a script named p1 with the following contents:

    echo $#
    echo $2 $1
    echo $*
    ls /zzxxwqsaer 2>/dev/null >/dev/null # /zzxxwqsaer does not exist
    echo $?

    What is the exact output if we run the script with the command line p1 Bob Leslie Sarah?








    9. Finish the shell script fragment so it gets input from the user and stores it in a variable called choice, then uses a case construct to run who | more if a or A is chosen, ps x if b or B is chosen, and w | more if c or C is chosen. DO NOT use a default case.

    while :
    do
    echo "A - Who's logged on"
    echo "B - List all my processes"
    echo "C - List everyone's current process"
    echo
    echo "Enter choice:\c"










    done

    10. What is the purpose of the colon ( after the while in the above script fragment?

    It's a special condition that means "Always True"

    Any advise would be much appreciated !!!

  2. #2
    oz
    oz is online now
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,096
    Sorry, but it's against the forum rules to post homework questions on the board:

    http://www.linuxforums.org/forum/lin...ums-rules.html

    Maybe you can ask your questions in some other way and someone can help.
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...