oplaTech About Teaching Archive
Oplatek's external memory

Week 8, Intro to Unix lab 2016

Content

  • Your job is to submitt correct solutions which work both on lab machine e.g u-pl24 and solaris u-us. If they won’t pass automatic test, 0 points will be rewarded!
    • It includes proper email subject and proper file naming
    • I will be sending back error messages
    • How to verify it on both: If you hate it, automate it.
  • Recap homework
    • sed -i not standard but useful
    • sed -e useful to use explicitly. Be careful of ordering of options especially -n
    • sed 1~2d is not standard. You can check http://pubs.opengroup.org/onlinepubs/9699919799/ after searching sed
    • functions are very useful but not standard
    • bashism
      • $(( 1 +2 ))
      • ((k++))
    • while cond ; do command ; done - no ; after do
    • while read x ; do echo $x ; done - how to detect end of file
    • escaping variables "$i"
    • indent in last homework
      • printf for find is not in standard
  • Recap test and Bonus from previous week
    • Solution where "he said she said: \"unix rocks\"" can be passed as arguments
  • Print lines 7-9 using sed from seq 10000. Measure time. What is the fastest solutions?
  • processes: fg, bf, Ctrl-C, Ctrl-Z, Ctrl-Y, jobs

Homework

I am sorry for my delay I was ill.

The deadline will be till next week May 5th 2016, 23:59.

Note that the scripts works on Solaris and Gentoo in MS Rotunda laboratory, so keep it that way. It will be evaluated on machine u-pl2[0-9] and u-ss.

  • (1 point) Understand and modify a script ifs.sh so it prints a template only for users whose login is a substring of their name.
    • See one line from many which match the criteria:
      • Uzivatel 'vyuka laborator' ma login 'vyuka' and uid (50000).
      • Understand what is a template and what are the variables which should differ for each line
      • Note that login vyuka is substring from users name vyuka laborator.
    • Send me
      • ifs_${YOUR_NICKNAME}.sh modified script
      • ifs_${YOUR_NICKNAME}.output the scripts output
  • (1 point) Understand and modify a script args.sh so it prints every second word (argument) from this single command set -- /usr/*
    • Send me - both args_${YOUR_NICKNAME}.sh and args_${YOUR_NICKNAME}.output
  • (1 point) Understand and modify a script kill.sh so produces these two desired lines into file kill.out.
    • Send me only the modified script named kill_${YOUR_NICKNAME}.sh, but modify only the three lines marked for modification.
    • See kill man page before running the script.
    • Follow the instructions in the kill.sh script and investigate its behaviour.
    • Desired output stored in file kill.out with two lines:
You should run this script and press Ctrl+C to see me
Runn kill and my PID. That should be enough

HW Solutions