Sign inSign up free

765. Read One Value From an INI File

medium 20 XP ~10 minHands-on lab

Several tools keep their settings in INI files. Write /home/student/bin/ini-get.sh FILE SECTION KEY.

Task

  • Print the value of KEY inside [SECTION] and exit 0. Keys outside that section don't count, even if they have the same name.
  • Spaces around section names, keys, = and values are ignored. Lines starting with ; or # (after optional spaces) are comments.
  • If the key appears more than once in the section, the last value wins.
  • If the section or key doesn't exist, print nothing and exit 1.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of Shell Scripting for Automation. Next step: Build JSON Safely From Shell Variables

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.