Bash mid-day session
Part 1: morning materials
- Answer any questions.
- Go together through the challenges, do some exercises, and debug problems.
Part 2: afternoon materials
- Review the program for this afternoon: you have 1h4m of videos to watch.
By the end of the day you should be able to:
- write a multi-line bash script and function
- process command-line arguments in this script / function
- search inside files with
grep
- search the filesystem with
find
- perform basic text manipulation with
sed
,tr
,awk
Some of the hands-on exercises we will do in the late-afternoon Zoom session:
- Write a function archive() to replace directories with their gzipped archives.
- Write a one-line command that will search for a string in all files in the current directory and all its subdirectories, and will hide errors (e.g. due to permissions).
- Write a one-line command that finds 5 largest files in the current directory and prints only their
names and file sizes in the human-readable format (indicating bytes, kB, MB, GB, …) in the decreasing
file-size order. Hint: use
find
,xargs
, andawk
.