Search⌘ K

Exercise: Case Statement and Associative Array

Explore how to implement Bash scripts that switch between user configuration files using the case statement and associative arrays. Learn to create symbolic links and control flow in scripts, strengthening your understanding of Bash conditional statements and array usage.

Exercise 1: case statement

There are two configuration files in the user’s home directory: .bashrc-home and .bashrc-work.

Write a script to switch between them. You can do that by copying one of the files to the path ~/.bashrc or creating a symbolic link. Use the option h for file .bashrc-home and option w for .bashrc-work.

Solve the ...