105.1 Customize and use the shell environment — Lesson 2

Livestream date: 2026-05-17

Weight 4

Key knowledge areas

  • Set environment variables (e.g. PATH) at login or when spawning a new shell.
  • Write Bash functions for frequently used sequences of commands.
  • Maintain skeleton directories for new user accounts.
  • Set command search path with the proper directory.

Homework 1:

let: more than arithmetic expression evaluation:

  1. Do a manpage or web search for let and its implications when setting variables and create a new local variable named my_val whose value is 10 — as a result of adding 5 and 5
  2. Now create another variable named your_val whose value is 5 — as a result of dividing the value of my_val into 2

Homework 2:

The result of a command in a variable? Of course, that is possible; it is called command substitution. Investigate it and study the following function named music_info:

music_info(){
latest_music=`ls -l1t ~/Music | head -n 6`
echo -e "Your latest 5 music files:\n$latest_music"
}

The result of the command ls -l1t ~/Music | head -n 6 becomes the value of the variable latest_music. Then the variable latest_music is referenced in the echo command (which outputs the total number of bytes occupied by the Music folder and the latest five music files stored in the Music folder — one per line).

Which of the following is a valid synonym for

latest_music=`ls -l1t ~/Music | head -n 6`

Option A:

latest_music=$(ls -l1t ~/Music| head -n 6)

Option B:

latest_music="(ls -l1t ~/Music| head -n 6)"

Option C:

latest_music=((ls -l1t ~/Music| head -n 6))

Homework 1

  1. not sure but like just declare it like this my_val=5+5 or maby my_val=(5+5)
  2. similar to the one above but to avoid escape char your_val=($my_val/2)

Homework 2

  1. option B would just be a string or faulty bash command and A would indicate that hole thing is multiple variables witch they are not but C is my pick becuse it basically turns multiple comands on to one

Looks like it’s missing back ticks (`).

1 Like