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 usefulsed -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 searchingsed
- functions are very useful but not standard
- bashism
$(( 1 +2 ))
- ((k++))
while cond ; do command ; done
- no;
after dowhile read x ; do echo $x ; done
- how to detect end of file- escaping variables
"$i"
- indent in last homework
printf
forfind
is not in standard
- Recap test and Bonus from previous week
- Solution where
"he said she said: \"unix rocks\""
can be passed as arguments
- Solution where
- Print lines
7-9
using sed fromseq 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 namevyuka laborator
.
- Send me
ifs_${YOUR_NICKNAME}.sh
modified scriptifs_${YOUR_NICKNAME}.output
the scripts output
- See one line from many which match the criteria:
- (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
andargs_${YOUR_NICKNAME}.output
- Send me - both
- (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:
- Send me only the modified script named