PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Komme mit Unix-Kurs-Aufgaben nicht weiter ...



timtaylorrr
05.10.2007, 09:42
Hi

Ich mach gerade einen Unix Kurs und muss folgende Aufgaben lösen. Ich möchte nicht die Lösung, jedoch wäre es super, wenn mir jemand ungefähr beschreiben könnte in knappen Worten was zu tun ist. Mein Englisch ist noch nicht so gut. ;.)

Tausendmal Danke!



Script 1

Pre-requisites
Create a file with x amount of lines in it, the content of your choice.

Write a script named 'firstline' that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top (the first line) of the file named in your second argument.

Note! The file must retain the original name

Script 2

Take a copy (backup) and amend the above script so that it now inserts the first argument into the middle of the file. Please note that no matter how many lines there are in your script it should always place the line of text in the middle. Name this script 'middleline'.

Note! Again the original file must retain it original name

Note!
The solution to the following problems can be achieved in anything from 10 to 25 lines of code, depending on your aproach. If you have used more than this then you are probably on the wrong track - think again!
Again, for the following and any subsequent exercises you ARE NOT permitted to use either SED or AWK.

Script 3

Pre-requisites

Run the command's below
env >> xx
env >> xx
env >> xx
env >> xx
env >> xx
You will now have a file called XX with the env redirected into it 5 times

Create a script named 'username' that takes 1 argument being a file, in this instance we will use the newly created file above xx. Read the input file and look for occurrences of the current user who is executing the script. On finding an occurrence of the username take that line and append it to a file and display a line number and a bracket against the saved line.

The newly created file should look similar to this:
1) PWD=/home/lee.ballancore
2) USER=lee.ballancore
3) MAIL=/var/spool/mail/lee.ballancore
4) LOGNAME=lee.ballancore
5) HOME=/home/lee.ballancore
6) PWD=/home/lee.ballancore
7) USER=lee.ballancore
8) MAIL=/var/spool/mail/lee.ballancore
9) LOGNAME=lee.ballancore
10) HOME=/home/lee.ballancore

Note! The use of a temporary file is not allowed

Script 4

Write a script named 'permissions' that takes a file as an argument. The script should be able to determine what permissions the owner, group and everybody has for the file passed in. The output should be displayed similar to this.

READ WRITE EXECUTE
OWNER LEE.BALLANCORE YES YES NO
GROUP USERS YES NO NO
EVERYBODY NO NO NO

Script 5

Create a script named 'userprocesses' which will allow you to find all users currently logged on to the system and display the processes they are running. The heading for each user must be their real name not their log in name.
I.e. my login name is lee.ballancore but my real name is Lee Ballancore
The users must not be displayed more than once.
The output should look similar to this.

Lee Ballancore
PID TTY TIME CMD
31799 pts/3 00:00:00 vim
31866 pts/3 00:00:00 vim
2495 pts/7 00:00:00 vim
8368 pts/0 00:00:00 vim
9544 pts/2 00:00:00 ps

Alistairr Rutherford
PID TTY TIME CMD
8368 pts/0 00:00:00 vim
9544 pts/2 00:00:00 ps

Write the output to a file.

Once complete, save the five scripts in your $HOME/coursework/chapter7 folder.

Bâshgob
05.10.2007, 11:21
Erstens ist hier nicht die Hausaufgabenhilfe,
und zweitens verstößt deine Überschrift gegen die Boardregeln.
Drittens solltest du dringend an deinem Englisch arbeiten, sonst bringt dir der Kurs nämlich gar nix.

devilz
05.10.2007, 11:31
Hab mal deinen Titel angepasst .... aber warum suchst du denn Hilfe?

Nur die Aufgaben hier zu posten kann u.a. auch gegen das Urheberrecht verstossen!
Bitte klär das mit deinem Kurs!