Ondřej Plátek Blog
PhD candidate@UFAL, Prague. LLM & TTS evaluation. Engineer. Researcher. Speaker. Father.

Week 4, Intro to Unix lab 2016

Content

  • Homework discussions - rights
    • limit number of arguments. Try ls /*/*/*/*
  • Recapitulation
    • numeric representation
    • permissions 000, 600, 700, 644, 755 what is the behaviour?
    • Show the names and login times of the currently logged in users
    • Quick recap test - show prikazy.txt
  • env, standard variables, calling script from anywhere and PATH variable
  • mail: mail me (email on white board) and yourself in carbon copy (cc) your login and your machine name so I can see where you are sitting
    • use one liner
  • write a pomodoro script which email to stretch every 20 minutes
  • last, sort, join, uniq, /ect/passwd # or getent passwd
  • if time, prepare for future:
    • find - look at the syntax till next time
      • print is not like printing - 1200 pages cost money
    • recap less, more, pg
    • sync

Homework

Send me both your scripts but also the files counts_days and days_counts

  • (2 points) Count number of logins to machine u-pl24 per day of week
    • hints:
      • last, sort, uniq
      • ssh YOUR_NAME@u-pl24.ms.mff.cuni.cz
    • Store the results to counts_days file in format:
  243 Mon
  992 Tue
  823 Wed
 1202 Thu
  602 Fri
  123 Sat
   32 Sun
  • (1 point) Swap the columns from counts_days
    • Keep the numbers aligned to the right side
    • Store the results to days_counts file in format:
    • Hints: cut, paste character positions
Mon  243
Tue  992
Wed  823
Thu 1202
Fri  602
Sat  123
Sun   32

Bonus

  • (0 points) Write your homework using vim
    • Finish vimtutor tutorial before starting
  • (1 point) Change homework from third week so you backup dotfiles and dotdirectories and change the directories permissions recursively and files recursively so you cannot change/delete them.
  • (1 point) How many users with first name Jan can login to Rotunda lab?
    • Submit the code and write me a number into the email
  • (1 point) Similarly to homework count number of logins to u-pl24 per first name of user
    • Hints:
      • join command
      • Do not use /etc/passwd but getent passwd in Rotunda lab
    • Send me also the output in first_names.txt file
  • (2 points) - Draw a histogram for days_counts file:
    • Suppose that the first two columns do not exceed 18 characters
    • Distribute 60 ‘=’ characters proportionally according counts
    • See example of desired output for only three days.
    • Send me also the output in histogram.txt file
    • See example output for data Mon 1, Tue 40, Wed 80
Mon  1 =
Tue 40 ====================
Wed 80 =======================================