#!/usr/bin/env luash -- Variable Interpolation Demo print("=== Variable Interpolation in Shell Commands ===\n") print("1. Basic variable interpolation:") service = "ssh" result = `pgrep #{service} | wc -l` print(" Processes named '" .. service .. "': " .. result) print("\n2. Multiple variables in one command:") dir = "/tmp" pattern = "*.log" files = `find #{dir} -name #{pattern} 2>/dev/null | wc -l` print(" Files matching '" .. pattern .. "' in " .. dir .. ": " .. files) print("\n3. Network connectivity check:") host = "google.com" ping_result = `ping -c 1 #{host} >/dev/null 2>&1 && echo "ok" || echo "fail"` print(" " .. host .. " is " .. (ping_result == "ok" and "reachable" or "unreachable")) print("\n4. Dynamic file operations:") filename = "README.md" if `test -f #{filename}` ~= "" then lines = `wc -l < #{filename}` print(" " .. filename .. " has " .. lines .. " lines") else print(" " .. filename .. " not found") end print("\n✨ Use #{variable} syntax to substitute Lua variables into shell commands!")